/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 4151072
* @summary Ensure that BufferedReader's methods handle the new line character
* following the carriage return correctly after a readLine
* operation that resulted in reading a line terminated by a
* carriage return (\r).
*/
public class ReadLine {
// Make sure that the reader does not wait for additional characters to
// be read after reading a new line.
{"LF-Only\n", "LF-Only"},
{"CR-Only\r", "CR-Only"},
};
// test 1 "LF-Only\n"
// test 2 "CR-Only\r"
for (int i = 0; i < 3; i++) {
reader = new BufferedReader(new
throw new RuntimeException("Read incorrect text");
}
// Now test the mark and reset operations. Consider two cases.
// 1. For lines ending with CR only.
markResetTest("Lot of textual data\rMore textual data\n",
"More textual data");
markResetTest("Lot of textual data\r\nMore textual data\n",
"More textual data");
// 3. Now for lines ending with LF only
markResetTest("Lot of textual data\nMore textual data\n",
"More textual data");
// terminated line.
reader = new BufferedReader(new
throw new RuntimeException("Read() failed");
// Need to ensure that a read(char[], int, int) following a readLine()
reader = new BufferedReader(new
char[] buf = new char[9];
throw new RuntimeException("Read(char[],int,int) failed");
}
throws IOException {
// Make sure that the reset point was set correctly.
throw new RuntimeException("Mark/Reset failed");
}
private char[] content;
private int limit;
}
throw new RuntimeException("Read past limit");
}
throws IOException
{
}
}
public void close() {}
}
}