| Developer's Daily | Java Q&A Center |
| main | java | perl | unix | dev directory | web log |
| Question: | How do I append data to the end of a text file with Java? |
| Answer: |
|
The solution I'm presenting here works with Java JDK 1.1.x and more recent versions of the JDK. I haven't including a JDK 1.0.x solution, because our belief is that JDK 1.0.x is only used at this time for applets. Because applets *generally* cannot access a filesystem, there isn't much call for appending data to files. If anyone is interested in seeing how to append data to a text file with JDK 1.0.x, just send us an e-mail. To answer this question, let's suppose you have a file named
398:08291998:Joe's Car Shop:101.00 399:08301998:Papa John's Pizza:16.50 You can easily append data to the end of the text file
by using the Here's a sample mini-application that appends data to
the end of the
The
This simple constructor indicates that you want to write to the file in append mode. Note: This code has been tested on a SCO UnixWare 7 computer running Java JDK 1.1.3. It has not currently been tested on other platforms. Please let us know if you try this code on other platforms and experience any problems. Click here to download the
|
Copyright
© 1998-2002 DevDaily Interactive, Inc.
All Rights Reserved.