|
1 | 1 | package org.baeldung.java.io; |
2 | 2 |
|
3 | 3 | import java.io.ByteArrayInputStream; |
| 4 | +import java.io.DataInputStream; |
4 | 5 | import java.io.File; |
5 | 6 | import java.io.FileInputStream; |
6 | 7 | import java.io.IOException; |
7 | 8 | import java.io.InputStream; |
| 9 | +import java.io.SequenceInputStream; |
8 | 10 |
|
9 | 11 | import org.apache.commons.io.FileUtils; |
10 | 12 | import org.apache.commons.io.IOUtils; |
@@ -74,6 +76,28 @@ public final void givenUsingPlainJava_whenConvertingFileToInputStream_thenCorrec |
74 | 76 | IOUtils.closeQuietly(targetStream); |
75 | 77 | } |
76 | 78 |
|
| 79 | + @Test |
| 80 | + public final void givenUsingPlainJava_whenConvertingFileToDataInputStream_thenCorrect() throws IOException { |
| 81 | + final File initialFile = new File("src/test/resources/sample.txt"); |
| 82 | + final InputStream targetStream = new DataInputStream(new FileInputStream(initialFile)); |
| 83 | + |
| 84 | + IOUtils.closeQuietly(targetStream); |
| 85 | + } |
| 86 | + |
| 87 | + @Test |
| 88 | + public final void givenUsingPlainJava_whenConvertingFileToSequenceInputStream_thenCorrect() throws IOException { |
| 89 | + final File initialFile = new File("src/test/resources/sample.txt"); |
| 90 | + final File anotherFile = new File("src/test/resources/anothersample.txt"); |
| 91 | + final InputStream targetStream = new FileInputStream(initialFile); |
| 92 | + final InputStream anotherTargetStream = new FileInputStream(anotherFile); |
| 93 | + |
| 94 | + InputStream sequenceTargetStream = new SequenceInputStream(targetStream, anotherTargetStream); |
| 95 | + |
| 96 | + IOUtils.closeQuietly(targetStream); |
| 97 | + IOUtils.closeQuietly(anotherTargetStream); |
| 98 | + IOUtils.closeQuietly(sequenceTargetStream); |
| 99 | + } |
| 100 | + |
77 | 101 | @Test |
78 | 102 | public final void givenUsingGuava_whenConvertingFileToInputStream_thenCorrect() throws IOException { |
79 | 103 | final File initialFile = new File("src/test/resources/sample.txt"); |
|
0 commit comments