@SuppressWarnings("fallthrough") public void mergeHeader(InputStream is) throws java.io.IOException {
  if (is == null)   return;
  char s[]=new char[10];
  int firstc=is.read();
  while (firstc != '\n' && firstc != '\r' && firstc >= 0) {
    int len=0;
    int keyend=-1;
    int c;
    boolean inKey=firstc > ' ';
    s[len++]=(char)firstc;
    parseloop: {
      while ((c=is.read()) >= 0) {
switch (c) {
case ':':
          if (inKey && len > 0)           keyend=len;
        inKey=false;
      break;
case '\t':
    c=' ';
case ' ':
  inKey=false;
break;
case '\r':
case '\n':
firstc=is.read();
if (c == '\r' && firstc == '\n') {
firstc=is.read();
if (firstc == '\r') firstc=is.read();
}
if (firstc == '\n' || firstc == '\r' || firstc > ' ') break parseloop;
c=' ';
break;
}
if (len >= s.length) {
char ns[]=new char[s.length * 2];
System.arraycopy(s,0,ns,0,len);
s=ns;
}
s[len++]=(char)c;
}
firstc=-1;
}
while (len > 0 && s[len - 1] <= ' ') len--;
String k;
if (keyend <= 0) {
k=null;
keyend=0;
}
 else {
k=String.copyValueOf(s,0,keyend);
if (keyend < len && s[keyend] == ':') keyend++;
while (keyend < len && s[keyend] <= ' ') keyend++;
}
String v;
if (keyend >= len) v=new String();
 else v=String.copyValueOf(s,keyend,len - keyend);
add(k,v);
}
}

@ SuppressWarnings ( "fallthrough" ) public void mergeHeader ( InputStream is ) throws java . io . IOException { if ( is == null ) return ; char s [ ] = new char [ 10 ] ; int firstc = is . read ( ) ; while ( firstc != '\n' && firstc != '\r' && firstc >= 0 ) { int len = 0 ; int keyend = - 1 ; int c ; boolean inKey = firstc > ' ' ; s [ len ++ ] = ( char ) firstc ; parseloop : { while ( ( c = is . read ( ) ) >= 0 ) { switch ( c ) { case ':' : if ( inKey && len > 0 ) keyend = len ; inKey = false ; break ; case '\t' : c = ' ' ; case ' ' : inKey = false ; break ; case '\r' : case '\n' : firstc = is . read ( ) ; if ( c == '\r' && firstc == '\n' ) { firstc = is . read ( ) ; if ( firstc == '\r' ) firstc = is . read ( ) ; } if ( firstc == '\n' || firstc == '\r' || firstc > ' ' ) break parseloop ; c = ' ' ; break ; } if ( len >= s . length ) { char ns [ ] = new char [ s . length * 2 ] ; System . arraycopy ( s , 0 , ns , 0 , len ) ; s = ns ; } s [ len ++ ] = ( char ) c ; } firstc = - 1 ; } while ( len > 0 && s [ len - 1 ] <= ' ' ) len -- ; String k ; if ( keyend <= 0 ) { k = null ; keyend = 0 ; } else { k = String . copyValueOf ( s , 0 , keyend ) ; if ( keyend < len && s [ keyend ] == ':' ) keyend ++ ; while ( keyend < len && s [ keyend ] <= ' ' ) keyend ++ ; } String v ; if ( keyend >= len ) v = new String ( ) ; else v = String . copyValueOf ( s , keyend , len - keyend ) ; add ( k , v ) ; } }
parse and merge a mime header from an input stream .
