1 /* |
1 /* |
2 * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
300 * of a line feed ('\n'), a carriage return ('\r'), a carriage return |
300 * of a line feed ('\n'), a carriage return ('\r'), a carriage return |
301 * followed immediately by a line feed, or by reaching the end-of-file |
301 * followed immediately by a line feed, or by reaching the end-of-file |
302 * (EOF). |
302 * (EOF). |
303 * |
303 * |
304 * @param ignoreLF If true, the next '\n' will be skipped |
304 * @param ignoreLF If true, the next '\n' will be skipped |
|
305 * @param term Output: Whether a line terminator was encountered |
|
306 * while reading the line; may be {@code null}. |
305 * |
307 * |
306 * @return A String containing the contents of the line, not including |
308 * @return A String containing the contents of the line, not including |
307 * any line-termination characters, or null if the end of the |
309 * any line-termination characters, or null if the end of the |
308 * stream has been reached without reading any characters |
310 * stream has been reached without reading any characters |
309 * |
311 * |
310 * @see java.io.LineNumberReader#readLine() |
312 * @see java.io.LineNumberReader#readLine() |
311 * |
313 * |
312 * @exception IOException If an I/O error occurs |
314 * @exception IOException If an I/O error occurs |
313 */ |
315 */ |
314 String readLine(boolean ignoreLF) throws IOException { |
316 String readLine(boolean ignoreLF, boolean[] term) throws IOException { |
315 StringBuffer s = null; |
317 StringBuffer s = null; |
316 int startChar; |
318 int startChar; |
317 |
319 |
318 synchronized (lock) { |
320 synchronized (lock) { |
319 ensureOpen(); |
321 ensureOpen(); |
320 boolean omitLF = ignoreLF || skipLF; |
322 boolean omitLF = ignoreLF || skipLF; |
|
323 if (term != null) term[0] = false; |
321 |
324 |
322 bufferLoop: |
325 bufferLoop: |
323 for (;;) { |
326 for (;;) { |
324 |
327 |
325 if (nextChar >= nChars) |
328 if (nextChar >= nChars) |