title: Maximum line length for BufferedReader.readLine() in Java?
body: <p>I use BufferedReader's <code>readLine()</code> method to read lines of text from a socket. </p>
  
  <p>There is no obvious way to limit the length of the line read. </p>
  
  <p>I am worried that the source of the data can (maliciously or by mistake) write a lot of data without any line feed character, and this will cause BufferedReader to allocate an unbounded amount of memory. </p>
  
  <p>Is there a way to avoid that? Or do I have to implement a bounded version of <code>readLine()</code> myself? </p>