Java Code Examples for org.apache.commons.io.input.NullInputStream#read()
The following examples show how to use
org.apache.commons.io.input.NullInputStream#read() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileBuffer.java From cyberduck with GNU General Public License v3.0 | 6 votes |
@Override public synchronized int read(final byte[] chunk, final Long offset) throws IOException { final RandomAccessFile file = random(); if(offset < file.length()) { file.seek(offset); if(chunk.length + offset > file.length()) { return file.read(chunk, 0, (int) (file.length() - offset)); } else { return file.read(chunk, 0, chunk.length); } } else { final NullInputStream nullStream = new NullInputStream(length); if(nullStream.available() > 0) { nullStream.skip(offset); return nullStream.read(chunk, 0, chunk.length); } else { return IOUtils.EOF; } } }
Example 2
Source File: DisabledChecksumComputeTest.java From cyberduck with GNU General Public License v3.0 | 5 votes |
@Test(expected = IOException.class) public void compute() throws Exception { final NullInputStream in = new NullInputStream(0L); new DisabledChecksumCompute().compute(in, new TransferStatus()); assertEquals(-1, in.read()); in.read(); }