View Single Post
  #3 (permalink)  
Old 07-04-2007, 07:50 AM
Marcus Marcus is offline
Member
 
Join Date: Jun 2007
Posts: 92
Marcus is on a distinguished road
Thanks for you help but I'm still having a little difficulty appending the text file.
When I use the following code to update the txt file it replaces all the existing records in the txt file, I only want it to update a particular record.
Code:
FileReader inputStream = null; FileWriter outputStream = null; try { inputStream = new FileReader("customers.txt"); } catch (FileNotFoundException ex) { ex.printStackTrace(); } try { outputStream = new FileWriter("customers.txt", true); } catch (IOException ex) { ex.printStackTrace(); } int c; try { while ((c = inputStream.read()) != -1) { outputStream.write(c); } } catch (IOException ex) { ex.printStackTrace(); } if (inputStream != null) { try { inputStream.close(); } catch (IOException ex) { ex.printStackTrace(); } if (outputStream != null) { try { outputStream.append(jTextField1.getText() + '|'); outputStream.append(jTextField2.getText() + '|'); outputStream.append(jTextField3.getText() + '|'); outputStream.append(jTextField4.getText() + '|'); outputStream.append(jTextField5.getText() + '|'); outputStream.append(jTextField6.getText() + '|'); outputStream.append(jTextArea1.getText() + '|'); outputStream.flush(); outputStream.close(); } catch (IOException ex) { ex.printStackTrace(); } } }
any idea? Thanks

Marcus
Reply With Quote