Scanner开发常用功能

阅读 64

2022-05-26

多用于读取硬盘中数据:
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());
}
}


精彩评论(0)

0 0 举报