private String[] extractDispositionInfo(String line) throws IOException {
  String[] retval=new String[4];
  String origline=line;
  line=origline.toLowerCase();
  int start=line.indexOf("content-disposition: ");
  int end=line.indexOf(";");
  if (start == -1 || end == -1) {
    throw new IOException("Content disposition corrupt: " + origline);
  }
  String disposition=line.substring(start + 21,end);
  if (!disposition.equals("form-data")) {
    throw new IOException("Invalid content disposition: " + disposition);
  }
  start=line.indexOf("name=\"",end);
  end=line.indexOf("\"",start + 7);
  int startOffset=6;
  if (start == -1 || end == -1) {
    start=line.indexOf("name=",end);
    end=line.indexOf(";",start + 6);
    if (start == -1) {
      throw new IOException("Content disposition corrupt: " + origline);
    }
 else     if (end == -1) {
      end=line.length();
    }
    startOffset=5;
  }
  String name=origline.substring(start + startOffset,end);
  String filename=null;
  String origname=null;
  start=line.indexOf("filename=\"",end + 2);
  end=line.indexOf("\"",start + 10);
  if (start != -1 && end != -1) {
    filename=origline.substring(start + 10,end);
    origname=filename;
    int slash=Math.max(filename.lastIndexOf('/'),filename.lastIndexOf('\\'));
    if (slash > -1) {
      filename=filename.substring(slash + 1);
    }
  }
  retval[0]=disposition;
  retval[1]=name;
  retval[2]=filename;
  retval[3]=origname;
  return retval;
}

private String [ ] extractDispositionInfo ( String line ) throws IOException { String [ ] retval = new String [ 4 ] ; String origline = line ; line = origline . toLowerCase ( ) ; int start = line . indexOf ( "content-disposition: " ) ; int end = line . indexOf ( ";" ) ; if ( start == - 1 || end == - 1 ) { throw new IOException ( "Content disposition corrupt: " + origline ) ; } String disposition = line . substring ( start + 21 , end ) ; if ( ! disposition . equals ( "form-data" ) ) { throw new IOException ( "Invalid content disposition: " + disposition ) ; } start = line . indexOf ( "name=\"" , end ) ; end = line . indexOf ( "\"" , start + 7 ) ; int startOffset = 6 ; if ( start == - 1 || end == - 1 ) { start = line . indexOf ( "name=" , end ) ; end = line . indexOf ( ";" , start + 6 ) ; if ( start == - 1 ) { throw new IOException ( "Content disposition corrupt: " + origline ) ; } else if ( end == - 1 ) { end = line . length ( ) ; } startOffset = 5 ; } String name = origline . substring ( start + startOffset , end ) ; String filename = null ; String origname = null ; start = line . indexOf ( "filename=\"" , end + 2 ) ; end = line . indexOf ( "\"" , start + 10 ) ; if ( start != - 1 && end != - 1 ) { filename = origline . substring ( start + 10 , end ) ; origname = filename ; int slash = Math . max ( filename . lastIndexOf ( '/' ) , filename . lastIndexOf ( '\\' ) ) ; if ( slash > - 1 ) { filename = filename . substring ( slash + 1 ) ; } } retval [ 0 ] = disposition ; retval [ 1 ] = name ; retval [ 2 ] = filename ; retval [ 3 ] = origname ; return retval ; }
extracts and returns disposition info from a line , as a < code > string < code > array with elements : disposition , name , filename .
