in src/main/java/com/aliyun/oss/common/utils/IniEditor.java [960:1017]
public void load(BufferedReader reader) throws IOException {
while (reader.ready()) {
reader.mark(NAME_MAXLENGTH);
String line = reader.readLine().trim();
// Check for section header
if (line.length() > 0 && line.charAt(0) == HEADER_START) {
reader.reset();
return;
}
int delimIndex = -1;
// blank line
if (line.equals("")) {
this.addBlankLine();
}
// comment line
else if ((delimIndex = Arrays.binarySearch(this.commentDelimsSorted, line.charAt(0))) >= 0) {
addComment(line.substring(1), this.commentDelimsSorted[delimIndex]);
}
// option line
else {
delimIndex = -1;
int delimNum = -1;
int lastSpaceIndex = -1;
for (int i = 0, l = line.length(); i < l && delimIndex < 0; i++) {
delimNum = Arrays.binarySearch(this.optionDelimsSorted, line.charAt(i));
if (delimNum >= 0) {
delimIndex = i;
} else {
boolean isSpace = Arrays.binarySearch(Section.OPTION_DELIMS_WHITESPACE, line.charAt(i)) >= 0;
if (!isSpace && lastSpaceIndex >= 0) {
break;
} else if (isSpace) {
lastSpaceIndex = i;
}
}
}
// delimiter at start of line
if (delimIndex == 0) {
// XXX what's a man got to do?
}
// no delimiter found
else if (delimIndex < 0) {
if (lastSpaceIndex < 0) {
this.set(line, "");
} else {
this.set(line.substring(0, lastSpaceIndex), line.substring(lastSpaceIndex + 1));
}
}
// delimiter found
else {
this.set(line.substring(0, delimIndex), line.substring(delimIndex + 1),
line.charAt(delimIndex));
}
}
}
}