Search in sources :

Example 1 with NullReader

use of org.apache.commons.io.input.NullReader in project commons-io by apache.

the class IOUtilsCopyTest method testCopy_readerToAppendable_IO84.

@Test
public void testCopy_readerToAppendable_IO84() throws Exception {
    final long size = (long) Integer.MAX_VALUE + (long) 1;
    final Reader reader = new NullReader(size);
    final NullWriter writer = new NullWriter();
    // Test copy() method
    assertEquals(size, IOUtils.copy(reader, (Appendable) writer));
    // reset the input
    reader.close();
    // Test copyLarge() method
    assertEquals(size, IOUtils.copyLarge(reader, writer), "copy()");
}
Also used : Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) NullReader(org.apache.commons.io.input.NullReader) NullReader(org.apache.commons.io.input.NullReader) NullWriter(org.apache.commons.io.output.NullWriter) Test(org.junit.jupiter.api.Test)

Example 2 with NullReader

use of org.apache.commons.io.input.NullReader in project commons-io by apache.

the class IOUtilsCopyTest method testCopy_readerToWriter_IO84.

/*
     * Test Copying file > 2GB  - see issue# IO-84
     */
@Test
public void testCopy_readerToWriter_IO84() throws Exception {
    final long size = (long) Integer.MAX_VALUE + (long) 1;
    final Reader reader = new NullReader(size);
    final Writer writer = new NullWriter();
    // Test copy() method
    assertEquals(-1, IOUtils.copy(reader, writer));
    // reset the input
    reader.close();
    // Test copyLarge() method
    assertEquals(size, IOUtils.copyLarge(reader, writer), "copyLarge()");
}
Also used : Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) NullReader(org.apache.commons.io.input.NullReader) NullReader(org.apache.commons.io.input.NullReader) NullWriter(org.apache.commons.io.output.NullWriter) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer) NullWriter(org.apache.commons.io.output.NullWriter) Test(org.junit.jupiter.api.Test)

Aggregations

InputStreamReader (java.io.InputStreamReader)2 Reader (java.io.Reader)2 NullReader (org.apache.commons.io.input.NullReader)2 NullWriter (org.apache.commons.io.output.NullWriter)2 Test (org.junit.jupiter.api.Test)2 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1