Hi,
i know how to read specific line form a text file but if we want to delete lines by specifying the line number.
here is the code, but it's not working:
i want to delete line 1 and 2 of the text file.
import java.io.*;
public class ReadSpecificLine
{
public static void main(String[] args){
String line = "";
int lineNo;
try
{
FileReader fr = new FileReader("C://Temp/File.txt");
BufferedReader br = new BufferedReader(fr);
for(lineNo=1;lineNo<3;lineNo++)
{
while (lineNo = 1&&2, br.readLine() !=null);
}
br.readLine();
}
}
catch (IOException e)
{
e.printStackTrace();
}
System.out.println("Line: " + line);
}
}
Thank you