in commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/UriParser.java [356:394]
public static String extractScheme(final String uri, final StringBuilder buffer) {
if (buffer != null) {
buffer.setLength(0);
buffer.append(uri);
}
final int maxPos = uri.length();
for (int pos = 0; pos < maxPos; pos++) {
final char ch = uri.charAt(pos);
if (ch == ':') {
// Found the end of the scheme
final String scheme = uri.substring(0, pos);
if (scheme.length() <= 1 && SystemUtils.IS_OS_WINDOWS) {
// This is not a scheme, but a Windows drive letter
return null;
}
if (buffer != null) {
buffer.delete(0, pos + 1);
}
return scheme.intern();
}
if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z') {
// A scheme character
continue;
}
if (!(pos > 0 && (ch >= '0' && ch <= '9' || ch == '+' || ch == '-' || ch == '.'))) {
// Not a scheme character
break;
}
// A scheme character (these are not allowed as the first
// character of the scheme), but can be used as subsequent
// characters.
}
// No scheme in URI
return null;
}