import java.io.*;
public class FileInputDemo
{
public static void main(String[] args)
{
try
{
FileInputStream f = new FileInputStream("mydata.txt");
DataInputStream in = new DataInputStream(f);
//BufferedReader br = new BufferedReader(new InputStreamReader(f));
while(in.available() != 0)
System.out.println(in.readLine());
/**
* DataInputStream.readLine()已经过时
* 使用 DataInputStream 类读取文本行的程序可以改为使用BufferedReader类
* 改用BufferedReader.readLine()方法
* 只要将以下形式的代码:DataInputStream d = new DataInputStream(in);
* 替换为:BufferedReader d = new BufferedReader(new InputStreamReader(in));
*/
in.close();
}
catch(Exception e)
{
System.err.println("File input error!");
}
}
}
posted on 2007-05-28 00:29
jadmin 阅读(84)
评论(0) 编辑 收藏