Why is this java code not # skipped?

I am a novice, but I try to allow Java scripts to read external Txt file can have some comments at the beginning of the file so that others can easily edit it and add more content

The following code section is used to process previously invoked in script. Comment line in TXT file:

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);
    }

input. Txt file breaks it on the first line:

This is an actual error:

And stack trace error:

Solution

Your first visible role may be preceded by a UTF - 8 byte order tag Most editors do not display these characters because it only predicts the encoding of the content, and Java does not remove UTF-8 byte order marks (different from utf-16 and 32) If UTF - 8 BOM does exist, you must delete these three bytes yourself

For more details, see Java bug 6378911

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>