Thread: line number
View Single Post
  #1 (permalink)  
Old 11-21-2007, 01:14 AM
kazitula kazitula is offline
Member
 
Join Date: Oct 2007
Posts: 10
kazitula is on a distinguished road
line number
hiya
i m new in java, i've written a code for file input,its working, but now i need to print the line number, i mean how many line it has printed. i attach the code here.
try
{
fin = new FileInputStream ("c:\\readfile.txt");
DataInputStream in = new DataInputStream(fin);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
System.out.println (strLine);
}
fin.close();
}

i use catch block for IOException.
this program can read from file line by line, and i need all the line numbers.
Thank you

kazitula
Reply With Quote
Sponsored Links