Java Reference
In-Depth Information
int index = -1;
int c;
do {
c = input.read();
buffer.append( (char)c );
index++;
}while ( (buffer.length() < boundary.length()) &&
(c == boundary.charAt(index)) );
if ( c == boundary.charAt(index) ){
int type = -1;
if ( input.read() == '-' )
type = -2;
while ( input.read() != LF );
return type;
}
while ( index >= 0 ){
input.unread( buffer.charAt(index));
index--;
}
return input.read();
}
private Hashtable parseHeader(String line){
Hashtable header = new Hashtable();
String token = null;
StringTokenizer st = new StringTokenizer(line,";");
while(st.hasMoreTokens()){
token = ((String)st.nextToken()).trim();
String key = "";
String val = "";
int eq = token.indexOf("=");
if(eq <0) eq = token.indexOf(":");
if(eq >0){
key = token.substring(0,eq).trim();
val = token.substring(eq+1);
val = val.replace('"',' ');
val = val.trim();
header.put(key,val);
}
}
return header;
Search WWH ::




Custom Search