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();                
}

}

You seem to be ignoring the end-of-line char(s).
What did you intend wih the two calls to readLine?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.