解决配置文件中特殊字符问题

This commit is contained in:
heavyrain2012
2021-08-05 15:44:20 +08:00
parent 5a2ded4b6e
commit debd4f1aea
@@ -84,20 +84,24 @@ class ConfigurationParser {
String line; String line;
try { try {
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
line = line.trim();
int commentMarker = line.indexOf('#'); int commentMarker = line.indexOf('#');
if (commentMarker != -1) { if (commentMarker != -1) {
if (commentMarker == 0) { if (commentMarker == 0) {
// skip its a comment // skip its a comment
continue; continue;
} else { } else {
// it's a malformed comment String[] ss = line.split(" ");
if(ss.length != 2) {
throw new ParseException(line, commentMarker); throw new ParseException(line, commentMarker);
} }
}
} else { } else {
if (line.isEmpty() || line.matches("^\\s*$")) { if (line.isEmpty() || line.matches("^\\s*$")) {
// skip it's a black line // skip it's a black line
continue; continue;
} }
}
// split till the first space // split till the first space
int delimiterIdx = line.indexOf(' '); int delimiterIdx = line.indexOf(' ');
@@ -112,7 +116,6 @@ class ConfigurationParser {
m_properties.put(key, value); m_properties.put(key, value);
} }
}
} catch (IOException ex) { } catch (IOException ex) {
throw new ParseException("Failed to read", 1); throw new ParseException("Failed to read", 1);
} finally { } finally {