2

I have to write on a file the data that I get from the fields that are already filled when a checkbox is checked.

Here is what I started write. (please note that I was guessing with the jChackBox1.isEnabled() I'm pretty sure that is wrong)

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    if(jCheckBox1.isEnabled()){
        try {
            FileOutputStream Backup = new FileOutputStream("BackupFile.txt");
            PrintStream write = new PrintStream(Backup);

        } catch (FileNotFoundException ex) {
            Logger.getLogger(Crypto.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}  

I have to get the text written in this two fields

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    try {
        String pwd = String.valueOf(jPasswordField1.getPassword());
        String EncryptionKey = "dhsakjh7324afe24";
        AESExample aes = new AESExample(EncryptionKey);
        String encpwd = aes.encrypt(pwd); //I NEED TO GET THE VALUE OF ENCPWD
        jTextArea1.setText("Encryption complete.\n\n" + encpwd); 
        String Desc = jTextField1.getText();//AND TO GET THIS VALUE

How can I do it? I haven't found anything.

Sam
  • 35
  • 5
  • 1
    And what is your exact problem or question? – Reporter Apr 29 '16 at 14:11
  • What have you tried? Where are you stuck? Which form have you decided to store the data in (plain text file, serialized objects, XML). For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). – Andrew Thompson Apr 29 '16 at 14:12
  • 1
    *"I haven't found anything."* Then you need to hone your search skills, but until you narrow down the problem, we can't even much help with that. – Andrew Thompson Apr 29 '16 at 14:14
  • lol well I'm not that good at programming, I'm more into Networking.. but I have to do it unfortunately.. – Sam Apr 29 '16 at 14:15
  • 1
    *"but I have to do it unfortunately."* Nobody said you had to complain to us about it. I'm just saying, since our interest in this is purely technical, we don't really give a toss how someone's day is going (or what their excuse is for expecting to be spoon fed). – Andrew Thompson Apr 29 '16 at 14:17
  • *"TextField and TextArea."* So as a plain text file? With the text field string at the first line, with the text area string(s) on subsequent lines? Or should the text field string be the last line? This might not be important when saving, but it will be vital when reading it back. *"I didn't found anything"* I only tried to search on some of the keywords in your question just now, and it did not turn up what I was expecting! So you have a good point there. Try the [Basic I/O](https://docs.oracle.com/javase/tutorial/essential/io/) lesson of the Java Tutorial. – Andrew Thompson Apr 29 '16 at 14:31
  • Sorry I read wrong the previous comment. I have to save in a simple .txt file and I have to save description and the encrypted pwd that are text. With the text field string at the first line, with the text area string on subsequent line – Sam Apr 29 '16 at 14:44

0 Answers0