code: public static String readline(InputStream input, boolean includeLF) throws IOException {
  		StringBuilder sb = new StringBuilder();
  		while (true) {
  			int c = input.read();
  			if (c == -1) {
  				if (sb.length() == 0)
  					throw new IOException("premature end of file");
  				break;
  			}
  			if (c != '\n' || includeLF)
  				sb.append((char) c);
  			if (c == '\n')
  				break;
  		}
  		return sb.toString();
  	}
docs: read a line of text, possibly including the terminating LF char