Solved

Appending to data files from java code

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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 …

762 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

24 Experts available now in Live!

Get 1:1 Help Now