0
点赞
收藏
分享

微信扫一扫

Scanner开发常用功能

多用于读取硬盘中数据:
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 条评论