0

I am want to delete the first line of text file using RandomAccessFile class.
My Input file "bulkwfids.txt"
has the data as below:
234567
345578
455678
566667

Expected output needs to be(first line deleted):
345578
455678
566667

But the actual ouput I am getting is as follows:
78
56
345578
455678
566667

Could someone please clear the doubt.
Here is the code snippet I have written:

import java.io.*;


class DeleteLine
 {
            public static void main(String [] args) throws FileNotFoundException, IOException
                {

                   RandomAccessFile raf = new RandomAccessFile("C://Users/hp/Desktop/bulkwfids.txt", "rw");
                   raf.readLine();

                int n=0;
                for(int i=0;i<3;i++)
                {
                byte [] buff = new byte[100];
                raf.read(buff);
                raf.seek(0);
                raf.write(buff,n,6);
                n=n+6;
                raf.readLine();


                } 


                raf.close();                
}

}
2
Contributors
1
Reply
15
Views
2 Years
Discussion Span
Last Post by JamesCherrill
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.