I am really sorry but I am still stuck. Please help.

Please can someone help me with the following code. I have a number of questions. So far all buttons that I have coded actions for work fine. When The program saves it does it correctly as I have seen the text file. However I have some problems.
1) How can I declare the arrays in another way without setting them to "" when the program starts. I need the program to start and show the previous saved arrays instead. I dont know if my method used for retrieving data from the file is correct either?.
2) When retrieving the values from a file that has example (all are string values). ADAM SANDLER 111 222 333 MICKY MOUSE 222 444 666
Where I want them to be in the follwing arrays as an example.
String name[1] = ADAM
String surname[1] = SANDLER
String home[1] = 111
String work[1] = 222
String cell[1] = 333
String name[2] = MICKY
String surname[2] = MOUSE
String home[2] = 222
String work[2] = 444
String cell[2] = 666
Here is my code.
     Filename:     ContactsListInterface.java
     Date:           16 March 2008
     Programmer:     Yucca Nel
     Purpose:     Provides a GUI for entering names and contact numbers into a telephone directory.
                    Also allows options for searching for a specific name and deleting of data from the record
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import java.io.*;
import java.util.*;
import java.text.*;
public class ContactsListInterface extends JFrame implements ActionListener
{ //start of class
     // Declare outputstream and inputStream
     DataOutputStream output;
     DataInputStream input;
     String filename = "phonebook";
     // construct fields, buttons, labels and text boxes
     JTextPane displayPane = new JTextPane();
     JLabel listOfContacts = new JLabel("List Of Contacts");               // creates a label for the scrollpane
     JButton createButton = new JButton("Create");
     JButton searchButton = new JButton("Search");
     JButton modifyButton = new JButton("Modify");
     JButton deleteButton = new JButton("Delete");
     // declare data arrays for name, surname, work number, home number and cell number
     private String name[] = {""};
     private String surname[] = {""};
     private String home[] = {""};
     private String work[] = {""};
     private String cell[] = {""};
     // create an instance of the ContactsListInterface
     public ContactsListInterface()
     { // start of cli()
          super("Phonebook Interface");
     } // end of cli()
     public JMenuBar createMenuBar()
     { // start of the createMenuBar()
          // construct and populate a menu bar
          JMenuBar mnuBar = new JMenuBar();                    // creates a menu bar
          setJMenuBar(mnuBar);
          JMenu mnuFile = new JMenu("File",true);               // creates a file menu in the menu bar which is visible
               mnuFile.setMnemonic(KeyEvent.VK_F);
               mnuFile.setDisplayedMnemonicIndex(0);
               mnuFile.setToolTipText("File Options");
               mnuBar.add(mnuFile);
          JMenuItem mnuFileExit = new JMenuItem("Exit");     // creates an exit option in the file menu
               mnuFileExit.setMnemonic(KeyEvent.VK_X);
               mnuFileExit.setDisplayedMnemonicIndex(1);
               mnuFileExit.setToolTipText("Close Application");
               mnuFile.add(mnuFileExit);
               mnuFileExit.setActionCommand("Exit");
               mnuFileExit.addActionListener(this);
          JMenu mnuEdit = new JMenu("Edit",true);               // creates a menu for editing options
               mnuEdit.setMnemonic(KeyEvent.VK_E);
               mnuEdit.setDisplayedMnemonicIndex(0);
               mnuEdit.setToolTipText("Edit Options");
               mnuBar.add(mnuEdit);
          JMenu mnuEditSort = new JMenu("Sort",true);          // creates an option for sorting entries
               mnuEditSort.setMnemonic(KeyEvent.VK_S);
               mnuEditSort.setDisplayedMnemonicIndex(0);
               mnuEdit.add(mnuEditSort);
          JMenuItem mnuEditSortByName = new JMenuItem("Sort By Name");          // to sort entries by name
               mnuEditSortByName.setMnemonic(KeyEvent.VK_N);
               mnuEditSortByName.setDisplayedMnemonicIndex(8);
               mnuEditSortByName.setToolTipText("Sort entries by first name");
               mnuEditSortByName.setActionCommand("Name");
               mnuEditSortByName.addActionListener(this);
               mnuEditSort.add(mnuEditSortByName);
          JMenuItem mnuEditSortBySurname = new JMenuItem("Sort By Surname");     // to sort entries by surname
               mnuEditSortBySurname.setMnemonic(KeyEvent.VK_R);
               mnuEditSortBySurname.setDisplayedMnemonicIndex(10);
               mnuEditSortBySurname.setToolTipText("Sort entries by surname");
               mnuEditSortBySurname.setActionCommand("Surname");
               mnuEditSortBySurname.addActionListener(this);
               mnuEditSort.add(mnuEditSortBySurname);
          JMenu mnuHelp = new JMenu("Help",true);                    // creates a menu for help options
               mnuHelp.setMnemonic(KeyEvent.VK_H);
               mnuHelp.setDisplayedMnemonicIndex(0);
               mnuHelp.setToolTipText("Help options");
               mnuBar.add(mnuHelp);
          JMenuItem mnuHelpHelp = new JMenuItem("Help");          // creates a help option for help topic
               mnuHelpHelp.setMnemonic(KeyEvent.VK_P);
               mnuHelpHelp.setDisplayedMnemonicIndex(3);
               mnuHelpHelp.setToolTipText("Help Topic");
               mnuHelpHelp.setActionCommand("Help");
               mnuHelpHelp.addActionListener(this);
               mnuHelp.add(mnuHelpHelp);
          JMenuItem mnuHelpAbout = new JMenuItem("About");     // creates a about option for info about api
               mnuHelpAbout.setMnemonic(KeyEvent.VK_T);
               mnuHelpAbout.setDisplayedMnemonicIndex(4);
               mnuHelpAbout.setToolTipText("About this program");
               mnuHelpAbout.setActionCommand("About");
               mnuHelpAbout.addActionListener(this);
               mnuHelp.add(mnuHelpAbout);
          return mnuBar;
     } // end of the createMenuBar()
     // create the content pane
     public Container createContentPane()
     { // start of createContentPane()
          // try blocks for the input and output
          try
               output = new DataOutputStream(new FileOutputStream(filename));
          catch(IOException io)
               JOptionPane.showMessageDialog(null,"This program could not create a storage location. Please check the disk drive and the tun the program again.","Error",JOptionPane.ERROR_MESSAGE);
               System.exit(1);
          //construct and populate panels and content pane
          JPanel labelPanel = new JPanel(); // panel is only used to put the label for the textpane in
               labelPanel.setLayout(new FlowLayout());
               labelPanel.add(listOfContacts);
          JPanel displayPanel = new JPanel();// panel is used to display all the contacts and thier numbers
               setTabsAndStyles(displayPane);
               displayPane = addTextToTextPane();
               displayPane.setEditable(false);
          JScrollPane scrollPane = new JScrollPane(displayPane);
               scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); // pane is scrollable vertically
               scrollPane.setWheelScrollingEnabled(true);// pane is scrollable by use of the mouse wheel
               scrollPane.setPreferredSize(new Dimension(400,320));
          displayPanel.add(scrollPane);
          JPanel workPanel = new JPanel();// panel is used to enter, edit and delete data
               workPanel.setLayout(new FlowLayout());
               workPanel.add(createButton);
                    createButton.setToolTipText("Create a new entry");
                    createButton.addActionListener(this);
               workPanel.add(searchButton);
                    searchButton.setToolTipText("Search for an entry by name number or surname");
                    searchButton.addActionListener(this);
               workPanel.add(modifyButton);
                    modifyButton.setToolTipText("Modify an existing entry");
                    modifyButton.addActionListener(this);
               workPanel.add(deleteButton);
                    deleteButton.setToolTipText("Delete an existing entry");
                    deleteButton.addActionListener(this);
          labelPanel.setBackground(Color.red);
          displayPanel.setBackground(Color.red);
          workPanel.setBackground(Color.red);
          // create container and set attributes
          Container c = getContentPane();
               c.setLayout(new BorderLayout(30,30));
               c.add(labelPanel,BorderLayout.NORTH);
               c.add(displayPanel,BorderLayout.CENTER);
               c.add(workPanel,BorderLayout.SOUTH);
               c.setBackground(Color.red);
          // add a listener for the window closing and save
          addWindowListener(
               new WindowAdapter()
                    public void windowClosing(WindowEvent e)
                         int answer = JOptionPane.showConfirmDialog(null,"Are you sure you would like to save all changes and exit?","File submission",JOptionPane.YES_NO_OPTION);
                         if(answer == JOptionPane.YES_OPTION)
                              save();
                              System.exit(0);
          return c;
     } // end of createContentPane()
     protected void setTabsAndStyles(JTextPane displayPane)
     { // Start of setTabsAndStyles()
          // set Font style
          Style fontStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
          Style regular = displayPane.addStyle("regular", fontStyle);
          StyleConstants.setFontFamily(fontStyle, "SansSerif");
          Style s = displayPane.addStyle("bold", regular);
          StyleConstants.setBold(s,true);
     } // End of setTabsAndStyles()
     public JTextPane addTextToTextPane()
     { // start of addTextToTextPane()
          try
               input = new DataInputStream(new FileInputStream(filename));
               for(int i=0; i<name.length;i++)
                    name[i] = input.readUTF();
                    surname[i] = input.readUTF();
                    home[i] = input.readUTF();
                    work[i] = input.readUTF();
                    cell[i] = input.readUTF();
          catch(IOException io)
          Document doc = displayPane.getDocument();
          try
          { // start of tryblock
               // clear previous text
               doc.remove(0,doc.getLength());
               // insert titles of columns
               doc.insertString(0,"NAME\tSURNAME\tHOME NO\tWORK NO\tCELL NO\n",displayPane.getStyle("bold"));
               // insert data
               for(int i=0; i<name.length; i++)
                    doc.insertString(doc.getLength(), name[i] +"\t",displayPane.getStyle("regular"));
                    doc.insertString(doc.getLength(), surname[i] +"\t",displayPane.getStyle("regular"));
                    doc.insertString(doc.getLength(), home[i]+"\t",displayPane.getStyle("regular"));
                    doc.insertString(doc.getLength(), work[i]+"\t",displayPane.getStyle("regular"));
                    doc.insertString(doc.getLength(), cell[i]+"\t",displayPane.getStyle("regular"));
          } // end of try block
          catch(BadLocationException ble)
          { // start of ble exception handler
               System.err.println("Could not insert text.");
          } // end of ble exception handler
          return displayPane;
     } // end of addTextToTextPane()
     // code to process user clicks
     public void actionPerformed(ActionEvent e)
     { // start of actionPerformed()
          String arg = e.getActionCommand();
          // user clicks exit option
          if(arg.equals("Exit"))
               int answer = JOptionPane.showConfirmDialog(null,"Exiting will save all changes to file. \nAre you sure you would like to save and exit now?","File submission",JOptionPane.YES_NO_OPTION);
               if(answer == JOptionPane.YES_OPTION)
                    save();
                    System.exit(1);
          // user clicks help option
          if(arg.equals("Help"))
               JOptionPane.showMessageDialog(null, "Welcome to the phone book application. To add a new entry press the \"Create\" button.\n To search for an entry press the \"Search\" button.\n To modify an existing entry press the \"Modify\" button. \n To delete an entry press the \"Delete\" button.","Help Topic",JOptionPane.INFORMATION_MESSAGE);
          // user clicks about option
          if(arg.equals("About"))
               JOptionPane.showMessageDialog(null,"Phonebook v 1.01 created by Yucca Nel.\nNo copyright exists.\nThis program is freeware and should not be sold.\nEnjoy :-)","About phonebook",JOptionPane.INFORMATION_MESSAGE);
          // user clicks create button
          if(arg.equals("Create"))
               createNew();
          // user clicks search button
          if(arg.equals("Search"))
               searchForName(arg, name);                    // Only possible to search by name as all contacts Must have a name
          if(arg.equals("Modify"))
               modifyContact(arg,name);
               save();
          // user clicks the sort by name option
          if(arg.equals("Name"))
               sort(name);
          if(arg.equals("Surname"))
               sort(surname);
     } // end of actionPerformed()
     // Method to ceate a new entry
     public void createNew()
     { // start of createNew()
          int newHome, newWork, newCell = 0;
          String newContactName = JOptionPane.showInputDialog(null,"Please enter the new contacts first name or press cancel to exit.");
          if(newContactName == null)     finish();                         // if user clicks cancel
          if(newContactName.length() <=0)
               JOptionPane.showMessageDialog(null,"You did not enter a valid name.\nPlease make sure you enter data correctly.","Error",JOptionPane.ERROR_MESSAGE);
               createNew();                                                  // To return to the create method
          String newContactSurname = JOptionPane.showInputDialog(null,"Please enter the new contacts surname or press cancel to exit.");
          if(newContactSurname == null)     finish();                    // if user clicks cancel
          if(newContactSurname.equals(""))
               int answer = JOptionPane.showConfirmDialog(null,"You did not enter a surname.\nAre you sure you wish to leave the surname empty?","No data entered",JOptionPane.YES_NO_OPTION);   // Asks if data was valid
               if(answer == JOptionPane.NO_OPTION)
                    newContactSurname = JOptionPane.showInputDialog(null,"Please enter the new contacts surname.");
          String newContactWorkNum = JOptionPane.showInputDialog(null,"Please enter the new contacts work number or press cancel to exit.");
          if(newContactWorkNum == null)   finish();                    // if user clicks cancel
          String newContactHomeNum = JOptionPane.showInputDialog(null,"Please enter the new contacts home number or press cancel to exit.");
          if(newContactHomeNum == null)     finish();                    // if user clicks cancel
          String newContactCellNum = JOptionPane.showInputDialog(null,"Please enter the new contacts cell number or press cancel to exit.");
          if(newContactCellNum == null)     finish();                    // if user clicks cancel
          // enlarge the arrays so they can accept data
          name = enlargeArray(name);
          surname = enlargeArray(surname);
          work = enlargeArray(work);
          home = enlargeArray(home);
          cell = enlargeArray(cell);
          // add the new data into the arrays
          name[name.length-1] = newContactName;
          surname[surname.length-1] = newContactSurname;
          home[home.length-1] = newContactHomeNum;
          work[work.length-1] = newContactWorkNum;
          cell[cell.length-1] = newContactCellNum;
          // sort the names so they appear in alphebetical order
          sort(name);
     } // end of createNew()
     // The enlarge array method
     //method to enlarge an array by 1
     public String[] enlargeArray(String[] currentArray)
          String[] newArray = new String[currentArray.length + 1];
          for (int i = 0; i < currentArray.length; i++)
          newArray[i] = currentArray;
          return newArray;
     }// End of enlargeArray()
     // The Sort Method
     public void sort(String tempArray[])
     { // start of sort()
          // for loop
          for(int pass = 1; pass < tempArray.length; pass++)
               for(int element = 0; element < tempArray.length -1; element++)
               if(tempArray[element].compareTo(tempArray[element+1])>0)
                    swap(name, element, element+1);
                    swap(surname, element, element+1);
                    swap(home, element, element+1);
                    swap(work, element, element+1);
                    swap(cell, element, element+1);
          addTextToTextPane();
     } // end of sort()
     // The swap method
     public void swap(String swapArray[], int first, int second)
     { // start of swap()
          String hold;
          hold = swapArray[first];
          swapArray[first] = swapArray[second];
          swapArray[second] = hold;
     } // end of swap()
     // method to search for a name
     public void searchForName(String searchField, String searchArray[])
     { // start of searchForName()
          try
               Document doc = displayPane.getDocument();                         // assign text to an object
               doc.remove(0,doc.getLength());                                        // clear the screen
               doc.insertString(0,"NAME\tSURNAME\tHOME NO\tWORK NO\tCELL NO\n",displayPane.getStyle("bold"));
               String searchValue = JOptionPane.showInputDialog(null,"Please enter the 1st name of the person you would like to see phone numbers for or press cancel to exit.");
               boolean found = false;
               if(searchValue == null) finish();                                   // if user clicks cancel
               //search the array
               for(int i=0; i < name.length; i++)
                    if(searchValue.compareTo(searchArray[i])==0)
                         doc.insertString(doc.getLength(), name[i] +"\t",displayPane.getStyle("regular"));
                         doc.insertString(doc.getLength(), surname[i] +"\t",displayPane.getStyle("regular"));
                         doc.insertString(doc.getLength(), home[i]+"\t",displayPane.getStyle("regular"));
                         doc.insertString(doc.getLength(), work[i]+"\t",displayPane.getStyle("regular"));
                         doc.insertString(doc.getLength(), cell[i]+"\t",displayPane.getStyle("regular"));
                         found = true;
               if(found == false)
                    JOptionPane.showMessageDialog(null,"No contact with that name found.","No result found",JOptionPane.INFORMATION_MESSAGE);
                    sort(name);
          catch(BadLocationException ble)
               System.err.println("Could not insert text.");
     } // end of searchForName()
     // Method to modify contact
     public void modifyContact(String searchField, String searchArray[])
     { // start of modifyContact()
          try
               Document doc = displayPane.getDocument();                         // assign text to an object
               doc.remove(0,doc.getLength());                                        // clear the screen
               doc.insertString(0,"NAME\tSURNAME\tHOME NO\tWORK NO\tCELL NO\n",displayPane.getStyle("bold"));
               String modifyValue = JOptionPane.showInputDialog(null,"Please enter the 1st name of the person you would like to change details for. Or press cancel to exit");
               boolean found = false;
               if(modifyValue == null)      finish();                              // if user clicks cancel
               //search the array
               for(int i=0; i < name.length; i++)
                    if(modifyValue.compareTo(searchArray[i])==0)
                         // To change the name
                         String oldName = name[i];
                         String newName = JOptionPane.showInputDialog(null,"Please enter a new name if you would like to change the name for "+name[i]+". Or press cancel to exit");
                         if(newName == null)
                              name[i] = oldName;                                        // if user clicks cancel keep old entry
                              finish();
                         if(newName.equals(""))                                        // if no data entered then name will stay same
                              JOptionPane.showMessageDialog(null,"You did not enter a name in the name field.\nOld name will be kept.","Information Message",JOptionPane.INFORMATION_MESSAGE);
                              name[i] = oldName;
                              addTextToTextPane();
                         else
                              name[i] = newName;                                        // new name is saved into array
                              addTextToTextPane();
                         //To change the surname
                         String oldSurname = surname[i];
                         String newSurname = JOptionPane.showInputDialog(null,"Please enter a new surname if you would like to change the surname for "+name[i]+". Or press cancel to exit");
                         if(newSurname == null)
                              surname[i] = oldSurname;                              // if user clicks cancel keep old entry
                              finish();
                         if((oldSurname.length()>0) && newSurname.length()<=0)          // if surname existed but no new surname was entered
                              int answer = JOptionPane.showConfirmDialog(null,"You are about to remove the surname for "+name[i]+".\nAre you sure you would like to remove the surname for this contact?","Please confirm the following",JOptionPane.YES_NO_OPTION);
                              if(answer == JOptionPane.YES_OPTION)               // user wishes to remove old surname and leave no surname in place
                                   surname[i] = newSurname;                         // new surname is saved into the array
                              else                                                       // user does not wish to remove surname
                                   surname[i] = oldSurname;                         // keep the old surname
                         else                                                            // just replace the surname with new one as everything seems fine
                              surname[i] = newSurname;
                         //To change the work number of contact
                         String oldWork = work[i];
                         String newWork = JOptionPane.showInputDialog(null,"Please enter a new work number if you would like to change the work number for "+name[i]+". Or press cancel to exit");
                         if(newWork == null)
                              work[i] = oldWork;                                        // user clicks cancel keep old entry
                              finish();
                         if((oldWork.length()>0) && newWork.length()<=0)          // if number existed but no new number was entered
                              int answer = JOptionPane.showConfirmDialog(null,"You are about to remove the work number for "+name[i]+".\nAre you sure you would like to remove the work number for this contact?","Please confirm the following",JOptionPane.YES_NO_OPTION);
                              if(answer == JOptionPane.YES_OPTION)               // user wishes to remove old number and leave no number in place
                                   work[i] = newWork;                                   // new number is saved into the array
                              else                                                       // user does not wish to remove number
                                   work[i] = oldWork;                                   // keep the old number
                         else                                                            // just replace the number with new one as everything seems fine
                              work[i] = newWork;
                         //To change the work number of contact
                         String oldHome = home[i];
                         String newHome = JOptionPane.showInputDialog(null,"Please enter a new home number if you would like to change the home number for "+name[i]+". Or press cancel to exit");
                         if(newHome == null)
                              home[i] = oldHome;                                        // if user clicks cancel keep old value
                              finish();
                         if((oldHome.length()>0) && newHome.length()<=0)          // if number existed but no new number was entered
                              int answer = JOptionPane.showConfirmDialog(null,"You are about to remove the home number for "+name[i]+".\nAre you sure you would like to remove the home number for this contact?","Please confirm the following",JOptionPane.YES_NO_OPTION);
                              if(answer == JOptionPane.YES_OPTION)               // user wishes to remove old number and leave no number in place
                                   home[i] = newHome;                                   // new number is saved into the array
                              else                                                       // user does not wish to remove number
                                   home[i] = oldHome;                                   // keep the old number
                         else                                                            // just replace the number with new one as everything seems fine
                              home[i] = newHome;
                         //To change the cell number
                         String oldCell = cell[i];
                         String newCell = JOptionPane.showInputDialog(null,"Please enter a new cell number if you would like to change the cell number for "+name[i]+". Or press cancel to exit");
                         if(newCell == null)
                              cell[i] = oldCell;                                        // if user clicks cancel keep old value
                              finish();
                         if((oldCell.length()>0) && newCell.length()<=0)          // if number existed but no new number was entered
                              int answer = JOptionPane.showConfirmDialog(null,"You are about to remove the Cell number for "+name[i]+".\nAre you sure you would like to remove the cell number for this contact?","Please confirm the following",JOptionPane.YES_NO_OPTION);
                              if(answer == JOptionPane.YES_OPTION)               // user wishes to remove old number and leave no number in place
                                   cell[i] = newCell;                                   // new number is saved into the array
                              else                                                       // user does not wish to remove number
                                   cell[i] = oldCell;                                   // keep the old number
                         else                                                            // just replace the number with new one as everything seems fine
                              cell[i] = newCell;
                         found = true;
                    addTextToTextPane();
               if(found == false)
                    JOptionPane.showMessageDialog(null,"No contact with that name found.","No result found",JOptionPane.INFORMATION_MESSAGE);
                    sort(name);
                    addTextToTextPane();
          catch(BadLocationException ble)
               System.err.println("Could not insert text.");
     } // end of searchForName()
     // finish method for cancel button
     public void finish()
          JOptionPane.showMessageDialog(null,"This program will now close and automatically save all data entered. You may restart the program to modify any changes.","Information Message",JOptionPane.INFORMATION_MESSAGE);
          System.exit(0);
     // method to save data to file
     public void save()
          try
               for(int i=0; i < name.length; i++)
                    output.writeUTF(name[i]);
                    output.writeUTF(surname[i]);
                    output.writeUTF(work[i]);
                    output.writeUTF(home[i]);
                    output.writeUTF(cell[i]);
               JOptionPane.showMessageDialog(null,"Data succesfully saved to file.","Information message",JOptionPane.INFORMATION_MESSAGE);
          catch(IOException io)
               System.exit(1);
     public static void main(String[] args)
     { // start of main()
          // Set look and feel of interface
          try
          { // start of try block
               UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
          } // end of try block
          catch(Exception e)
          { // start of catch block
               JOptionPane.showMessageDialog(null,"There was an error in setting the look and feel of this application","Error",JOptionPane.INFORMATION_MESSAGE);
          } // end of catch block
          ContactsListInterface cli = new ContactsListInterface();
          cli.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
          cli.setJMenuBar(cli.createMenuBar());
          cli.setContentPane(cli.createContentPane());
          cli.setSize(520,500);
          cli.setVisible(true);
          cli.setResizable(false);
     } // end of main()
} //end of classBefore thinking I am lazy I dont want you to correct my code. Just give me a few pointers on how to get my arrays back from the file and how to set my strings to  a non null value that wont show when my program starts.
Edited by: Yucca on Mar 24, 2008 7:24 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              

Yucca wrote:
It's pretty easy to write objects to file, but it depends on what you want to do with that file. Do you want it to be a human-readable text file? Is it only to be used by your program? The file is to be used by my program to save to and to read from. But I understand now that saving each entry as a string and not writing it to an array may be easier. Do I use the buffered reader instead of InputStreamReader? Oh sorry I forgot to mention that the file I save to will later be used when I convert my application to a database type/SQL tyype aplication.
Edited by: Yucca on Mar 24, 2008 8:06 PMIt sounds to me like object serialization would be the easiest for what you want to do. Read through this:
http://java.sun.com/developer/technicalArticles/Programming/serialization/
And these apis:
http://java.sun.com/j2se/1.5.0/docs/api/java/io/ObjectOutputStream.html
http://java.sun.com/j2se/1.5.0/docs/api/java/io/ObjectInputStream.html

Similar Messages

Maybe you are looking for