private Map<String, List<String>> loadPartHeaders(InputStream in) throws IOException { StringBuilder buffer = new StringBuilder(128); StringBuilder b = new StringBuilder(128); Map<String, List<String>> heads = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); // loop until we hit the end or a null line while (readLine(in, b)) { // lines beginning with white space get special handling char c = b.charAt(0); if (c == ' ' || c == '\t') { if (buffer.length() != 0) { // preserve the line break and append the continuation buffer.append("\r\n"); buffer.append(b); } } else { // if we have a line pending in the buffer, flush it if (buffer.length() > 0) { addHeaderLine(heads, buffer); buffer.setLength(0); } // add this to the accumulator buffer.append(b); } } // if we have a line pending in the buffer, flush it if (buffer.length() > 0) { addHeaderLine(heads, buffer); } return heads; }
private Map<String, List<String>> loadPartHeaders(InputStream in) throws IOException { StringBuilder buffer = new StringBuilder(128); StringBuilder b = new StringBuilder(128); Map<String, List<String>> heads = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); // loop until we hit the end or a null line while (readLine(in, b)) { // lines beginning with white space get special handling char c = b.charAt(0); if (c == ' ' || c == '\t') { if (buffer.length() != 0) { // preserve the line break and append the continuation buffer.append("\r\n"); buffer.append(b); } } else { // if we have a line pending in the buffer, flush it if (buffer.length() > 0) { addHeaderLine(heads, buffer); buffer.setLength(0); } // add this to the accumulator buffer.append(b); } } // if we have a line pending in the buffer, flush it if (buffer.length() > 0) { addHeaderLine(heads, buffer); } return heads; }