private static int nextToken(String url, int pos, StringBuffer token)
{
token.setLength(0);
while (pos < url.length()) {
char ch = url.charAt(pos++);
if (ch == ':' || ch == ';') {
break;
}
if (ch == '/') {
if (pos < url.length() && url.charAt(pos) == '/') {
pos++;
}
break;
}
token.append(ch);
}
return pos;
}
上面代碼中token.setLength(0);的作用是每次都把字符串緩沖區清空,也就是重置的作用.
上面代碼作用是每次得到指定的一段.例如"jdbc:jtds:sqlserver://hostname/dbname"
token為jdbc,jtds,sqlserver,hostname,dbname
token.setLength(0);
while (pos < url.length()) {
char ch = url.charAt(pos++);
if (ch == ':' || ch == ';') {
break;
}
if (ch == '/') {
if (pos < url.length() && url.charAt(pos) == '/') {
pos++;
}
break;
}
token.append(ch);
}
return pos;
}
上面代碼中token.setLength(0);的作用是每次都把字符串緩沖區清空,也就是重置的作用.
上面代碼作用是每次得到指定的一段.例如"jdbc:jtds:sqlserver://hostname/dbname"
token為jdbc,jtds,sqlserver,hostname,dbname