Solved

Appending to data files from java code

Posted on 1997-06-25
1
175 Views
Last Modified: 2010-04-16
I need to write an application that appends data to an exisiting data file.  From what I can determine, all of the Java xxxOutputStream classes want to create a new file rather than appending.

I have to believe this is something I'm overlooking, rather than something the Java group forgot.
0
Comment
Question by:gutz041897
1 Comment
 
LVL 2

Accepted Solution

by:
mgk earned 100 total points
ID: 1222152
You're right - you overlooked it! Check out java.io.RandomAccessFile for some answers.

RandomAccessFile allows you to choose where in a file you want to write (or read) some bytes, text and so on. To append data to a file just use length() to get the file size and then write the data at that point.

Mark King
Ampersand Internet
http://www.powerup.com.au/~mgk
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question