org.apache.commons.io.input.ClosedInputStream Java Examples

The following examples show how to use org.apache.commons.io.input.ClosedInputStream. 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: ByteArrayOutputStream.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 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));
}
 
Example #2
Source File: ByteArrayOutputStream.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 2.5
 */
public synchronized InputStream toInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    final List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
    for (final byte[] buf : buffers) {
        final int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    reuseBuffers = false;
    return new SequenceInputStream(Collections.enumeration(list));
}
 
Example #3
Source File: EmptyEntityResolver.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public InputSource resolveEntity(String publicId, String systemId) {
  return new InputSource(ClosedInputStream.CLOSED_INPUT_STREAM);
}
 
Example #4
Source File: EmptyEntityResolver.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public InputStream resolveEntity(String publicId, String systemId, String baseURI, String namespace) {
  return ClosedInputStream.CLOSED_INPUT_STREAM;
}
 
Example #5
Source File: XmlOffsetCorrector.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public InputStream resolveEntity(String publicId, String systemId, String baseURI, String namespace) {
  return ClosedInputStream.CLOSED_INPUT_STREAM;
}
 
Example #6
Source File: EmptyEntityResolver.java    From hadoop-solr with Apache License 2.0 4 votes vote down vote up
@Override
public InputSource resolveEntity(String publicId, String systemId) {
  return new InputSource(ClosedInputStream.CLOSED_INPUT_STREAM);
}
 
Example #7
Source File: EmptyEntityResolver.java    From hadoop-solr with Apache License 2.0 4 votes vote down vote up
@Override
public InputStream resolveEntity(String publicId, String systemId, String baseURI,
    String namespace) {
  return ClosedInputStream.CLOSED_INPUT_STREAM;
}
 
Example #8
Source File: XmlOffsetCorrector.java    From SolrTextTagger with Apache License 2.0 4 votes vote down vote up
@Override
public InputStream resolveEntity(String publicId, String systemId, String baseURI, String namespace) {
  return ClosedInputStream.CLOSED_INPUT_STREAM;
}