code: public final String readLine() throws IOException {
          StringBuilder line = new StringBuilder(80); // Typical line length
          boolean foundTerminator = false;
          long unreadPosition = 0;
          while (true) {
              int nextByte = read();
              switch (nextByte) {
                  case -1:
                      return line.length() != 0 ? line.toString() : null;
                  case (byte) '\r':
                      if (foundTerminator) {
                          seek(unreadPosition);
                          return line.toString();
                      }
                      foundTerminator = true;
                      /* Have to be able to peek ahead one byte */
                      unreadPosition = getFilePointer();
                      break;
                  case (byte) '\n':
                      return line.toString();
                  default:
                      if (foundTerminator) {
                          seek(unreadPosition);
                          return line.toString();
                      }
                      line.append((char) nextByte);
              }
          }
      }
docs: Reads a line of text form the current position in this file. A line is
  represented by zero or more characters followed by {@code '\n'}, {@code
  '\r'}, {@code "\r\n"} or the end of file marker. The string does not
  include the line terminating sequence.
  <p>
  Blocks until a line terminating sequence has been read, the end of the
  file is reached or an exception is thrown.
  
  @return the contents of the line or {@code null} if no characters have
  been read before the end of the file has been reached.
  @throws IOException
  if this file is closed or another I/O error occurs.