Solved

Appending to data files from java code

Posted on 1997-06-25
1
174 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apps blocked by Java 9 88
ejb wildfly example 2 17
ejb mdb examples 1 6
Java 8 to Java 6 8 20
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

808 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