import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class Java_moodi1 { public static void main(String[] args) { //*********Found******** Path pfile = __________________; try { //*********Found******** BufferedReader br = __________________; String str = null; //*********Found******** while((__________________!=null){ System.out.println(str); } } catch (IOException e) { e.printStackTrace(); } } }完善这个程序
时间: 2023-08-11 14:08:10 浏览: 189
JDK1.7 之java.nio.file.Files 读取文件仅需一行代码实现
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class Java_moodi1 {
public static void main(String[] args) {
Path pfile = Paths.get("file.txt");
try {
BufferedReader br = Files.newBufferedReader(pfile);
String str = null;
while ((str = br.readLine()) != null) {
System.out.println(str);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
阅读全文