扫描仪文本文件无效

时间:2017-10-16 09:52:24

标签: java string java.util.scanner

我正在尝试使用字符(start /?pt,...)扫描文本文件,以便每个字母与特定图像匹配。但首先我必须阅读这封信,然后用图像建立连接。

a

1 个答案:

答案 0 :(得分:0)

嗯,你确定你正确宣布了你的扫描仪吗? 它应该是这样的:

Scanner sc = new Scanner(new File("FilePath"));
while(sc.hasNextLine()){
   String letters = sc.nextLine();
   System.out.println(letters);
}

这样您就可以阅读文件中的每个字母。