`

打开一个文本文件,每次读取一行内容,将每行作为一个字符串读入,并将字符串输出显示

 
阅读更多
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Printlnt {
public static void main(String args[]) throws IOException {
File filePath = new File("D:\\A.txt");
BufferedReader br;
String s = null;
try {
br = new BufferedReader(new FileReader(filePath));
while ((s = br.readLine()) != null) {
System.out.println(s + "\r\n");
}
} catch (FileNotFoundException e) {

e.printStackTrace();
}


}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics