Solved

Appending to data files from java code

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
json example 39 132
base64 decode encode 12 121
@SBGen Method 3 38
Apps blocked by Java 9 63
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now