I'm trying to parse a file into a Map. The text I'm trying to parse (displayed by sys out in log) is
10 przysuń hotel o 90 metrów
. With each word separated by \t
The file is UTF-8 encoded.
Here's my method:
private void readFile() {
try {
if (transcriptFile == null)
transcriptFile = new File(transcriptPath);
lines = Files.readAllLines(transcriptFile.toPath());
for (String s : lines) {
if (!s.isEmpty()) {
List<String> parts = Arrays.asList(s.split("\t"));
System.out.println(parts);
int id = Integer.parseInt(parts.get(0).trim());
parts.remove(0);
String text = String.join(" ",parts);
map.put(id,text);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
And I'm getting this exception:
[10, przysuń, hotel, o, 90, metrów ]
java.lang.NumberFormatException: For input string: "10"
at
java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at Controller.readFile(Controller.java:143)
at Controller.access$000(Controller.java:29)
at Controller$SpeechTask.call(Controller.java:202)
at Controller$SpeechTask.call(Controller.java:154)
at javafx.concurrent.Task$TaskCallable.call(Task.java:1423)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:748)
I see no reason why this would not be parsable.