简体   繁体   中英

how to store and retrieve items?

I need to store all encrypted messages so it may be retrieved and displayed by pressing a button, that is, press the button 3 times for the last 3rd message;

After retrieving an encrypted message , let user guess (type into a textbox) the original message and press a button. Display how many characters are correct and how many wrong.

Really sorry for the bad question. here's an example of my current coding. basically i take the input from a textfield. so how do i store and retrieve the input?

String input = txtInput.getText();

StringBuilder builder = new StringBuilder(); 
char[] charArray =  input.toCharArray(); 

for(int i = 0; i < charArray.length; i +=2) 
{ 
    if(i+1 < charArray.length) 
    { 
        //even 
        builder.append(charArray[i+1]); 
    } 
    //odd 
    builder.append(charArray[i]); 
} 

String flippedText = builder.toString(); 
lblencryted.setText(flippedText); 

for(int i = 0; i < 100; i++){ 
    String[] storeArray = {flippedText};     
} 

}                                         

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)     {                                          
String input = txtInput.getText(); 

StringBuilder builder = new StringBuilder(); 
char[] charArray =  input.toCharArray(); 

for(int i = 0; i < charArray.length; i +=2) 
{ 
    if(i+1 < charArray.length) 
    { 
        //even 
        builder.append(charArray[i+1]); 
    } 
    //odd 
    builder.append(charArray[i]); 
} 

String flippedText = builder.toString(); 
lblretrieve.setText(flippedText);  
}                                         

public static void main(String args[]) { 
    java.awt.EventQueue.invokeLater(new Runnable() { 
        public void run() { 
            new Encryption().setVisible(true); 
        } 
    }); 
} 

Check out the JDBC api .

If your texts are short than I would recommend Needleman–Wunsch algorithm go see how much matches there are.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM