import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.io.*;
import java.nio.file.Paths;
import edu.princeton.cs.algs4.StdOut;
public class test{
public static void main(String[] args) throws IOException
{
Scanner scanner = new Scanner(Paths.get("a.txt"),"utf-8");
//Scanner scanner = new Scanner(Paths.get("C:\\Users\\LHM\\algs4\\code\\test\\a.txt"),"utf-8");
//Scanner scanner = new Scanner(new File("a.txt"));
while(scanner.hasNextLine())
{
String line = scanner.nextLine();
StdOut.println(line);
}
}
}
java 文件输入demo
最新推荐文章于 2024-05-21 07:00:00 发布