PDA

Click to See Complete Forum and Search --> : readLine() and .dat


quipy
Apr 27th, 2003, 10:02 PM
hey there!
how do i read each line in a .dat file? is it the same way as reading a .txt file?

crptcblade
Apr 27th, 2003, 10:13 PM
As long as the information in the file is just plain text, it doesn't matter what the extension of the file is...

import java.io.*;

public class Test
{
public static void main(String args[])
{
try
{
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("c:\\status.txt")));
String s = "";

while ((s=br.readLine())!=null)
{
System.out.println(s);
}
} catch (Exception e){}

}

}