Results 1 to 5 of 5
  1. #1
    Radu is offline Member
    Join Date
    Dec 2009
    Posts
    29
    Rep Power
    0

    Question Help with JAVA Address Book Demo

    Hello!
    I'm trying to modify JAVA Address Book Demo from Using Java DB in Desktop Applications so the contacts will be saved in a text file and not using DB? I tried modifying this program but I didn't managed to save contacts in a txt file.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default

    Why not? What did you try? Where did you get stuck?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Radu is offline Member
    Join Date
    Dec 2009
    Posts
    29
    Rep Power
    0

    Exclamation

    Java Code:
     Thread salvareFisier=new Thread() {
            public void run(){
                for(int i=0; i<5; i%=5){
                    try {
                        Thread.sleep(300000);
                    } catch (InterruptedException ex) {
                        JOptionPane.showMessageDialog(null,"Salvarea automata a esuat!","Eroare",JOptionPane.ERROR_MESSAGE);
                    }
                    FileOutputStream fos2=null;
                    try {
                        fos2 = new FileOutputStream(fisier);
                    } catch (FileNotFoundException ex) {
                        JOptionPane.showMessageDialog(null,"Salvarea automata a esuat!","Eroare",JOptionPane.ERROR_MESSAGE);
                    }
                    ObjectOutputStream oos2=null;
                    try {
                        oos2 = new ObjectOutputStream(fos2);
                        oos2.writeObject(agenda);
                        oos2.close();
                    } catch (IOException ex) {
                        JOptionPane.showMessageDialog(null,"Salvarea automata a esuat!","Eroare",JOptionPane.ERROR_MESSAGE);
                    }
                }
            };
        };

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default

    ...okay, and what was the problem? What does that do? What would you expect it to do?

    If you want help, you have to be specific. Post an SSCCE that demonstrates exactly what you're doing and the problem you're having. That doesn't mean post your whole project- boil it down to the bare minimum.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Radu is offline Member
    Join Date
    Dec 2009
    Posts
    29
    Rep Power
    0

    Exclamation

    That is the thread that save the DB in the choosen file, once at every 5 minutes.


    This is the what the save button action must do:
    Java Code:
      private void jMenuItemSaveActionPerformed(java.awt.event.ActionEvent evt) {                                              
    // TODO add your handling code here:
            JFileChooser fc=new JFileChooser();
            int rezultat=fc.showSaveDialog(this);
            FileOutputStream fos=null;
            if(rezultat==JFileChooser.APPROVE_OPTION){
                try {
                    fos = new FileOutputStream(fc.getSelectedFile());
                } catch (FileNotFoundException ex) {
                    JOptionPane.showMessageDialog(this,"Fisier invalid!","Eroare",JOptionPane.ERROR_MESSAGE);
                }
                try {
                    ObjectOutputStream oos=new ObjectOutputStream(fos);
                    oos.writeObject(agenda);
                    oos.close();
                    
                } catch (IOException ex) {
                    JOptionPane.showMessageDialog(this,"Eroare de scriere!","Eroare",JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    I also attached the entire program.
    Attached Files Attached Files

Similar Threads

  1. Replies: 1
    Last Post: 02-17-2010, 06:28 AM
  2. java address book problems
    By Ekul in forum AWT / Swing
    Replies: 3
    Last Post: 11-11-2009, 07:14 PM
  3. Replies: 0
    Last Post: 07-02-2008, 08:11 PM
  4. Programming an Address book
    By d.anthonii in forum New To Java
    Replies: 0
    Last Post: 12-31-2007, 05:26 PM
  5. Address Book Server RC1 - 20 June 2007
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 06-22-2007, 06:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •