我可以用java.io
和java.util.Scanner
讀取文件,但我不知道怎麼只有java.util.Scanner
使用讀取文件:的Java讀取文件中使用掃描儀
import java.io.*;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
String filePath = "C:\\IdeaProjects\\test\\src\\input.txt";
Scanner sc = new Scanner(new File(filePath));
int a, b;
a = sc.nestInt();
b = sc.nextInt();
}
}
有人能幫忙嗎?
[閱讀使用掃描儀類Java中的.txt文件(可能的重複http://stackoverflow.com/questions/13185727/reading-a-txt-文件使用掃描儀類功能於JAVA) –