Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed. @return A String containing the contents of the line, not including any line-termination characters, or null if the e
()
| 152 | * or null if the end of the stream has been reached |
| 153 | */ |
| 154 | @Override |
| 155 | public String readLine() throws IOException { |
| 156 | StringBuilder result = new StringBuilder(); |
| 157 | for (;;) { |
| 158 | int intRead = read(); |
| 159 | if (intRead == -1) { |
| 160 | return result.length() == 0 ? null : result.toString(); |
| 161 | } |
| 162 | |
| 163 | char c = (char)intRead; |
| 164 | if (c == '\n' || c == '\r') break; |
| 165 | result.append(c); |
| 166 | } |
| 167 | return result.toString(); |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Skips characters. |