多用于读取硬盘中数据:
Scanner mScanner=new Scanner(new FileInputStream(new File(“C:\AutoSubmit.java”)));
mScanner.nextLine();//读取的数据
//逐行扫描文件,并逐行输出
public static void main(String[] args) throws FileNotFoundException {
InputStream in = new FileInputStream(new File("C:\\AutoSubmit.java"));
Scanner s = new Scanner(in);
while(s.hasNextLine()){
System.out.println(s.nextLine());
}
}