code: public static byte[] readLine(InputStream in) throws IOException {
  		int BUFF_LENGTH = 256;
  		byte[] buf = new byte[BUFF_LENGTH];
  
  		int i = 0;
  		int loops = 0;
  		int ch = 0;
  
  		while (true) {
  			ch = in.read();
  			if (ch < 0) {
  				break;
  			}
  			loops++;
  
  			// skip a leading LF's
  			if (loops == 1 && ch == LF) {
  				continue;
  			}
  
  			if (ch == CR || ch == LF) {
  				break;
  			}
  
  			if (i >= buf.length) {
  				byte[] oldBuf = buf;
  				buf = new byte[oldBuf.length + BUFF_LENGTH];
  				System.arraycopy(oldBuf, 0, buf, 0, oldBuf.length);
  			}
  			buf[i++] = (byte) ch;
  		}
  
  		if (ch == -1 && i == 0) {
  			return null;
  		}
  
  		// skip a trailing LF if it exists
  		if (ch == CR && in.available() >= 1 && in.markSupported()) {
  			in.mark(1);
  			ch = in.read();
  			if (ch != LF) {
  				in.reset();
  			}
  		}
  
  		byte[] oldBuf = buf;
  		buf = new byte[i];
  		System.arraycopy(oldBuf, 0, buf, 0, i);
  
  		return buf;
  	}
docs: /* ------------------------------------------------------------