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******** try { //*********Found******** //*********Found******** } } catch (IOException e) { e.printStackTrace(); } } }完善这个程序
时间: 2023-08-11 19:07:12 浏览: 185
JDK1.7 之java.nio.file.Files 读取文件仅需一行代码实现
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) {
try {
Path pfile = Paths.get("file.txt");
byte[] data = Files.readAllBytes(pfile);
String content = new String(data);
System.out.println(content);
} catch (IOException e) {
e.printStackTrace();
}
}
}
阅读全文