|
-
October 10th, 2004, 04:41 PM
#1
Senior Member
End of file
Hello Guys.
I have written the code to scann display every line of the text file, but the problem i that I do not know how do we do the End Of File in Java, Na i am using "null", therefore it becomes the endless loop.
Any sort of information will be appriciated.
the following is the code.
-------------------------------------
import java.io.*;
class ReadOne
{
public static void main(String[] args)throws IOException
{
FileReader f1 = new FileReader("E:\\Harbir\\ep04ext.txt");
BufferedReader file = new BufferedReader(f1);
String text;
int i=0;
while(file.readLine()!= null)
{
i++; // counting the number of lines
text=file.readLine();
System.out.println("\n "+text);
}
System.out.println("\n The value of I is: "+i);
}
}
--------------------------------------------------------------
U get What U pay for. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|