-
October 20th, 2001, 03:04 AM
#1
random access file
The following java fragment of code is meant to append text to a file using the RandomAccessFile class
RandomAccessFile inputfile = new RandomAccessFile("myfilein","r");
RandomAccessFile outputfile = new RandomAccessFile("myfileout","rw");
outputfile.seek(outputfile.length());
String line
//what do the following lines do?
while ((line=inputfile.readLine() !=null)
{
outputfile.writeBytes(Line);
outputfile.writeByte('\n');
}
inputfile.close();
outputfile.close();
Thanks in advance
-
October 20th, 2001, 04:28 AM
#2
Re: random access file
line=inputfile.readLine() reads the inputfile until it encounters a "\n" character and transfers the line (without "\n") into line. line is then written to the outputfile, followed by a new line "\n" character.
----------------
You can contact me directly at Christoph.Schulze@gmx.co.uk
Don't forget your parsley cause you can't eat your dog after having stolen him from some animal shelter and having drowned him in the Atlantic Ocean.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|