Solved

Appending to data files from java code

Posted on 1997-06-25
1
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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…
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:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

636 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