From 357c71a96a3203a72324c96eac381e0719125de4 Mon Sep 17 00:00:00 2001 From: DOHA Date: Mon, 6 Oct 2014 09:28:15 +0200 Subject: [PATCH] Change input file extension Change input file extension from .txt to .in --- .../java/io/JavaReadFromFileTest.java | 24 +++++++++--------- core-java/src/test/resources/test_read.in | 1 + core-java/src/test/resources/test_read1.in | 1 + core-java/src/test/resources/test_read2.in | 1 + core-java/src/test/resources/test_read3.in | 1 + core-java/src/test/resources/test_read4.in | Bin 0 -> 7 bytes core-java/src/test/resources/test_read7.in | 1 + core-java/src/test/resources/test_read8.in | 2 ++ 8 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 core-java/src/test/resources/test_read.in create mode 100644 core-java/src/test/resources/test_read1.in create mode 100644 core-java/src/test/resources/test_read2.in create mode 100644 core-java/src/test/resources/test_read3.in create mode 100644 core-java/src/test/resources/test_read4.in create mode 100644 core-java/src/test/resources/test_read7.in create mode 100644 core-java/src/test/resources/test_read8.in diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaReadFromFileTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaReadFromFileTest.java index 5ad6959707..72f658eb06 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaReadFromFileTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaReadFromFileTest.java @@ -33,7 +33,7 @@ public class JavaReadFromFileTest { public void whenReadWithBufferedReader_thenCorrect() throws IOException { final String expected_value = "Hello world"; - final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read.txt")); + final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read.in")); final String currentLine = reader.readLine(); reader.close(); @@ -42,7 +42,7 @@ public class JavaReadFromFileTest { @Test public void whenReadWithScanner_thenCorrect() throws IOException { - final Scanner scanner = new Scanner(new File("src/test/resources/test_read1.txt")); + final Scanner scanner = new Scanner(new File("src/test/resources/test_read1.in")); scanner.useDelimiter(" "); assertTrue(scanner.hasNext()); @@ -56,7 +56,7 @@ public class JavaReadFromFileTest { @Test public void whenReadWithScannerTwoDelimiters_thenCorrect() throws IOException { - final Scanner scanner = new Scanner(new File("src/test/resources/test_read2.txt")); + final Scanner scanner = new Scanner(new File("src/test/resources/test_read2.in")); scanner.useDelimiter(",| "); assertTrue(scanner.hasNextInt()); @@ -69,7 +69,7 @@ public class JavaReadFromFileTest { @Test public void whenReadWithStreamTokenizer_thenCorrectTokens() throws IOException { - final FileReader reader = new FileReader("src/test/resources/test_read3.txt"); + final FileReader reader = new FileReader("src/test/resources/test_read3.in"); final StreamTokenizer tokenizer = new StreamTokenizer(reader); tokenizer.nextToken(); @@ -89,7 +89,7 @@ public class JavaReadFromFileTest { final String expected_value = "Hello"; String result; - final DataInputStream reader = new DataInputStream(new FileInputStream("src/test/resources/test_read4.txt")); + final DataInputStream reader = new DataInputStream(new FileInputStream("src/test/resources/test_read4.in")); result = reader.readUTF(); reader.close(); @@ -100,8 +100,8 @@ public class JavaReadFromFileTest { final int expected_value1 = 2000; final int expected_value2 = 5000; - final FileInputStream stream1 = new FileInputStream("src/test/resources/test_read5.txt"); - final FileInputStream stream2 = new FileInputStream("src/test/resources/test_read6.txt"); + final FileInputStream stream1 = new FileInputStream("src/test/resources/test_read5.in"); + final FileInputStream stream2 = new FileInputStream("src/test/resources/test_read6.in"); final SequenceInputStream sequence = new SequenceInputStream(stream1, stream2); final DataInputStream reader = new DataInputStream(sequence); @@ -117,7 +117,7 @@ public class JavaReadFromFileTest { @Test public void whenReadUTFEncodedFile_thenCorrect() throws IOException { final String expected_value = "青空"; - final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/test_read7.txt"), "UTF-8")); + final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/test_read7.in"), "UTF-8")); final String currentLine = reader.readLine(); reader.close(); @@ -127,7 +127,7 @@ public class JavaReadFromFileTest { @Test public void whenReadFileContentsIntoString_thenCorrect() throws IOException { final String expected_value = "Hello world \n Test line \n"; - final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read8.txt")); + final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read8.in")); final StringBuilder builder = new StringBuilder(); String currentLine = reader.readLine(); while (currentLine != null) { @@ -144,7 +144,7 @@ public class JavaReadFromFileTest { @Test public void whenReadWithFileChannel_thenCorrect() throws IOException { final String expected_value = "Hello world"; - final RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.txt", "r"); + final RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); final FileChannel channel = reader.getChannel(); int bufferSize = 1024; @@ -161,7 +161,7 @@ public class JavaReadFromFileTest { @Test public void whenReadSmallFileJava7_thenCorrect() throws IOException { final String expected_value = "Hello world"; - final Path path = Paths.get("src/test/resources/test_read.txt"); + final Path path = Paths.get("src/test/resources/test_read.in"); final String read = Files.readAllLines(path).get(0); assertEquals(expected_value, read); @@ -171,7 +171,7 @@ public class JavaReadFromFileTest { public void whenReadLargeFileJava7_thenCorrect() throws IOException { final String expected_value = "Hello world"; - final Path path = Paths.get("src/test/resources/test_read.txt"); + final Path path = Paths.get("src/test/resources/test_read.in"); final BufferedReader reader = Files.newBufferedReader(path); final String line = reader.readLine(); assertEquals(expected_value, line); diff --git a/core-java/src/test/resources/test_read.in b/core-java/src/test/resources/test_read.in new file mode 100644 index 0000000000..70c379b63f --- /dev/null +++ b/core-java/src/test/resources/test_read.in @@ -0,0 +1 @@ +Hello world \ No newline at end of file diff --git a/core-java/src/test/resources/test_read1.in b/core-java/src/test/resources/test_read1.in new file mode 100644 index 0000000000..1e46242993 --- /dev/null +++ b/core-java/src/test/resources/test_read1.in @@ -0,0 +1 @@ +Hello world 1 \ No newline at end of file diff --git a/core-java/src/test/resources/test_read2.in b/core-java/src/test/resources/test_read2.in new file mode 100644 index 0000000000..fe47dc003b --- /dev/null +++ b/core-java/src/test/resources/test_read2.in @@ -0,0 +1 @@ +2,3 4 \ No newline at end of file diff --git a/core-java/src/test/resources/test_read3.in b/core-java/src/test/resources/test_read3.in new file mode 100644 index 0000000000..db9f25a672 --- /dev/null +++ b/core-java/src/test/resources/test_read3.in @@ -0,0 +1 @@ +Hello 1 \ No newline at end of file diff --git a/core-java/src/test/resources/test_read4.in b/core-java/src/test/resources/test_read4.in new file mode 100644 index 0000000000000000000000000000000000000000..5727d54bfcb2046f4989fd13cf5dcf408201fa2a GIT binary patch literal 7 OcmZQz^+?Uh$p-)htO5D} literal 0 HcmV?d00001 diff --git a/core-java/src/test/resources/test_read7.in b/core-java/src/test/resources/test_read7.in new file mode 100644 index 0000000000..28d4d45d43 --- /dev/null +++ b/core-java/src/test/resources/test_read7.in @@ -0,0 +1 @@ +青空 \ No newline at end of file diff --git a/core-java/src/test/resources/test_read8.in b/core-java/src/test/resources/test_read8.in new file mode 100644 index 0000000000..10fc1aac8a --- /dev/null +++ b/core-java/src/test/resources/test_read8.in @@ -0,0 +1,2 @@ +Hello world + Test line