use of org.apache.commons.io.input.ClosedInputStream in project jackrabbit by apache.
the class RepositoryConfigTest method testRepositoryConfigCreateWithInputStream.
/**
* Tests that an input stream can be used for the configuration.
*/
public void testRepositoryConfigCreateWithInputStream() throws IOException {
InputStream input = new FileInputStream(XML);
try {
RepositoryConfig.create(input, DIR.getPath());
} catch (ConfigurationException e) {
fail("Valid configuration input stream");
} finally {
input.close();
}
try {
RepositoryConfig.create(new InputStream() {
public int read() throws IOException {
throw new IOException("invalid input stream");
}
}, DIR.getPath());
fail("Invalid configuration input stream");
} catch (ConfigurationException e) {
}
try {
RepositoryConfig.create(new ClosedInputStream(), DIR.getPath());
fail("Invalid configuration input stream");
} catch (ConfigurationException e) {
}
}
use of org.apache.commons.io.input.ClosedInputStream in project applause by applause.
the class ByteArrayOutputStream method toBufferedInputStream.
/**
* Gets the current contents of this byte stream as a Input Stream. The
* returned stream is backed by buffers of <code>this</code> stream,
* avoiding memory allocation and copy, thus saving space and time.<br>
*
* @return the current contents of this output stream.
* @see java.io.ByteArrayOutputStream#toByteArray()
* @see #reset()
* @since Commons IO 2.0
*/
private InputStream toBufferedInputStream() {
int remaining = count;
if (remaining == 0) {
return new ClosedInputStream();
}
List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
for (byte[] buf : buffers) {
int c = Math.min(buf.length, remaining);
list.add(new ByteArrayInputStream(buf, 0, c));
remaining -= c;
if (remaining == 0) {
break;
}
}
return new SequenceInputStream(Collections.enumeration(list));
}
use of org.apache.commons.io.input.ClosedInputStream in project jackrabbit by apache.
the class TempFileInputStream method close.
@Override
public void close() throws IOException {
in.close();
in = new ClosedInputStream();
file.delete();
}
Aggregations