Hi,
i'm a beginner in Java.
i'm just trying to code a program that extract some specificline from a text file.
for example :
i want to extract line No 5000 and lineNo 5100 and lineNo 5200.
Here is my code, but it only extract just one line from my text file.
Actually i can extract only one line. (LineNo = 5134)
thank you very much.
import java.io.*;
public class ReadSpecificLine
{
public static void main(String[] args){
String line = "";
int lineNo;
try
{
FileReader fr = new FileReader("C:\\IMS.txt");
BufferedReader br = new BufferedReader(fr);
for(lineNo=1;lineNo<10700;lineNo++)
{
if(lineNo==5134)
{
line = br.readLine();
}
else br.readLine();
}
}
catch (IOException e)
{
e.printStackTrace();
}
System.out.println("Line: " + line);
}
}