Merge pull request #5084 from dkapil/task/BAEL-8497

Task/bael 8497
This commit is contained in:
Loredana Crusoveanu 2018-08-27 21:22:16 +03:00 committed by GitHub
commit 710a40be08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -1,10 +1,12 @@
package org.baeldung.java.io; package org.baeldung.java.io;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.SequenceInputStream;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
@ -74,6 +76,28 @@ public class JavaXToInputStreamUnitTest {
IOUtils.closeQuietly(targetStream); IOUtils.closeQuietly(targetStream);
} }
@Test
public final void givenUsingPlainJava_whenConvertingFileToDataInputStream_thenCorrect() throws IOException {
final File initialFile = new File("src/test/resources/sample.txt");
final InputStream targetStream = new DataInputStream(new FileInputStream(initialFile));
IOUtils.closeQuietly(targetStream);
}
@Test
public final void givenUsingPlainJava_whenConvertingFileToSequenceInputStream_thenCorrect() throws IOException {
final File initialFile = new File("src/test/resources/sample.txt");
final File anotherFile = new File("src/test/resources/anothersample.txt");
final InputStream targetStream = new FileInputStream(initialFile);
final InputStream anotherTargetStream = new FileInputStream(anotherFile);
InputStream sequenceTargetStream = new SequenceInputStream(targetStream, anotherTargetStream);
IOUtils.closeQuietly(targetStream);
IOUtils.closeQuietly(anotherTargetStream);
IOUtils.closeQuietly(sequenceTargetStream);
}
@Test @Test
public final void givenUsingGuava_whenConvertingFileToInputStream_thenCorrect() throws IOException { public final void givenUsingGuava_whenConvertingFileToInputStream_thenCorrect() throws IOException {
final File initialFile = new File("src/test/resources/sample.txt"); final File initialFile = new File("src/test/resources/sample.txt");

View File

@ -0,0 +1 @@
...Continues