使用newInputStream()方法读取文件的内容
import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; /* *来 自 N o w J a v a . c o m */ import java.nio.file.Paths; public class Main { public static void main(String[] args) { Path path = Paths.get("C:/folder1/equipment", "test.txt"); int n; try (InputStream in = Files.newInputStream(path)) { while ((n = in.read()) != -1) { System.out.print((