会出现问题,因为我想从文本文件中制作标签,然后将其放入 VBOX,我得到 inputmismatchexception 并且它不制作新对象
VBox vertikalBox = new VBox();
try (Scanner s = new Scanner("rebricek.txt")) {
while (s.hasNext()) {
//InputMismatchException
vertikalBox.getChildren().addAll(new Label(""+ s.nextInt() + " " + s.next() + " " + s.nextInt()));
s.nextLine();
}
} catch (Throwable t) {
// inputmismatchexception - PROBLEM
// this is for NoSuchElementException
System.err.println("Vyskytla sa chyba pri praci zo suborom");
}
文件内容:
1 nikto 10
2 nikto 0
3 nikto 0
4 nikto 0
5 nikto 0
6 nikto 0
7 nikto 0
8 nikto 0
9 nikto 0
10 nikto 0