for (int i = 0 ; i < headerLines.length ; ){ StringTokenizer stTokens = new StringTokenizer(headerLines[i++], ";", false);
for (int i = 0 ; i <= lastHeader ; ++i){ String currentHeader = headerLines[i]; if (currentHeader.startsWith("Content-Type")) { String contentType = currentHeader .substring(currentHeader.indexOf(':')+1); int semiColonPos = contentType.indexOf(';'); if (semiColonPos != -1) contentType = contentType.substring(0, semiColonPos); nameValuePairs.put("content-type", contentType.trim()); continue; }
    private Hashtable parseHeader(String header)    {        int index = 0;        String[] headerLines;        Hashtable nameValuePairs = new Hashtable();        StringTokenizer stLines = new StringTokenizer(header, "\n", false);        headerLines = new String[stLines.countTokens()];        // Get all the header lines        while ( stLines.hasMoreTokens() )            headerLines[ index++ ] = stLines.nextToken();        for (int i = 0 ; i < headerLines.length ; ){            StringTokenizer stTokens = new StringTokenizer(headerLines[i++], ";", false);            // Get all the tokens from each line            if ( stTokens.countTokens() > 1 ){                stTokens.nextToken();    // Skip fist Token Content-Disposition: form-data                StringTokenizer stnameValue = new StringTokenizer(stTokens.nextToken(), "=", false);                nameValuePairs.put(stnameValue.nextToken().trim(), trim(stnameValue.nextToken(), "\""));                // This is a file                if ( stTokens.hasMoreTokens() ){                    stnameValue = new StringTokenizer(stTokens.nextToken(), "=", false);                    String formType = stnameValue.nextToken().trim();  // String Object default function                    String filePath = trim(stnameValue.nextToken(), "\""); // Our own trim function.                    // If is a DOS file get rid of drive letter and colon  "e:"                    if ( filePath.indexOf(":") != -1 )                        filePath = filePath.substring( (filePath.indexOf(":")+1) );                    //Get rid of PATH                    filePath = filePath.substring(filePath.lastIndexOf(File.separator) + 1);                    nameValuePairs.put(formType, filePath);                }            }        }        return nameValuePairs;    }