I'm a little newbie, but I'm trying to resolve an external .txt file that is read by a Java script, be able to add comments at the beginning of the file so that others can easily edit it. and add more to it. But if the file contains # (the character designated for the line, which is a comment), it simply returns an error that there is a βFormat error in fileβ (an IOException exception, so it passes this first βIFβ ...) Maybe someone any help?
Here's the piece of code that processes comment lines from a .txt file that was called earlier in the script:
while ((line = br.readLine()) != null) { line = line.trim(); if (line.length() < 1 || line.charAt(0) == '#') { // ignore comments continue; } final String[] parts = line.split("="); if (parts.length != 2) { throw new IOException("Format error in file " + JLanguageTool.getDataBroker().getFromRulesDirAsUrl(getFileName()) + ", line: " + line); }
The input.txt file splits it into the first line:
And here is the actual error:
Caused by: java.io.IOException: Format error in file
File: / D: / documents ....... / coherency.txt, line: # This is a test in rules.km.KhmerSimpleReplaceRule.loadWords (KhmerSimpleReplaceRule.java:165) in rules.km.KhmerSimpleReplaceRule.loadWords (KhmerSimpleReplaceRule. java: 82) ... 33 more info
And the stack trace error:
Called: java.io.IOException: Format error in file [Ljava.lang.StackTraceElement; @ 1cb2795 at km.KhmerSimpleReplaceRule.loadWords (KhmereSimpleReplaceRule.java: 169)
java file-io
Nathan
source share