Here you can find the source of readLineStringBuilder(InputStream is)
private static String readLineStringBuilder(InputStream is) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.InputStream; public class Main { private static String readLineStringBuilder(InputStream is) throws Exception { // FIXME con StringBuilder OutOfMemoryError sul NAS di Telecom String res = null;//w w w.j a va 2 s. co m StringBuilder sb = new StringBuilder(192); // most of the lines are shorter than 192 chars int temp = is.read(); while (temp != 0x0D) { if (sb.capacity() >= 4000) { // System.out.println("InternetUltil.readLineStringBuilder: sb.toString() " + sb.toString()); // System.out.println("InternetUltil.readLineStringBuilder: sb.length() " + sb.length() + " sb.capacity() " + sb.capacity()); sb.setLength(0); sb = null; return null; // reset the sb to avoid the out of memory exception } sb.append((char) temp); temp = is.read(); } is.read(); // skip (char)0x0A // if(sb.length() > 1000){ // System.out.println("InternetUltil.readLineStringBuilder: sb.toString() " + sb.toString()); // System.out.println("InternetUltil.readLineStringBuilder: sb.length() " + sb.length() + " sb.capacity() " + sb.capacity()); // } res = sb.toString(); sb = null; return res; } }