in src/main/java/org/apache/commons/io/FileSystemUtils.java [416:456]
long parseDir(final String line, final String path) throws IOException {
// read from the end of the line to find the last numeric
// character on the line, then continue until we find the first
// non-numeric character, and everything between that and the last
// numeric character inclusive is our free space bytes count
int bytesStart = 0;
int bytesEnd = 0;
int j = line.length() - 1;
innerLoop1: while (j >= 0) {
final char c = line.charAt(j);
if (Character.isDigit(c)) {
// found the last numeric character, this is the end of
// the free space bytes count
bytesEnd = j + 1;
break innerLoop1;
}
j--;
}
innerLoop2: while (j >= 0) {
final char c = line.charAt(j);
if (!Character.isDigit(c) && c != ',' && c != '.') {
// found the next non-numeric character, this is the
// beginning of the free space bytes count
bytesStart = j + 1;
break innerLoop2;
}
j--;
}
if (j < 0) {
throw new IOException("Command line 'dir /-c' did not return valid info for path '" + path + "'");
}
// remove commas and dots in the bytes count
final StringBuilder buf = new StringBuilder(line.substring(bytesStart, bytesEnd));
for (int k = 0; k < buf.length(); k++) {
if (buf.charAt(k) == ',' || buf.charAt(k) == '.') {
buf.deleteCharAt(k--);
}
}
return parseBytes(buf.toString(), path);
}