CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2001
    Posts
    80

    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




  2. #2
    Join Date
    Jan 2001
    Location
    Germany
    Posts
    222

    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.
    Teamwork Software - Stuff That Does Something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured