Package org.apache.solr.common.util

# Class ContentStreamBase.ByteArrayStream

java.lang.Object
org.apache.solr.common.util.ContentStreamBase
org.apache.solr.common.util.ContentStreamBase.ByteArrayStream

All Implemented Interfaces:
  `ContentStream`

Enclosing class:
  `ContentStreamBase`

public static class ContentStreamBase.ByteArrayStream extends ContentStreamBase
Construct a `ContentStream` from a `File`

## Nested Class Summary

## Nested classes/interfaces inherited from class org.apache.solr.common.util.ContentStreamBase

`ContentStreamBase.ByteArrayStream, ContentStreamBase.FileStream, ContentStreamBase.StringStream, ContentStreamBase.URLStream`

## Field Summary

### Fields inherited from class org.apache.solr.common.util.ContentStreamBase

`APPLICATION_GZIP, APPLICATION_JSON, APPLICATION_OCTET_STREAM, APPLICATION_XML, contentType, DEFAULT_CHARSET, name, size, sourceInfo, TEXT_XML`

## Constructor Summary

Constructors
Constructor
Description
`ByteArrayStream(byte[] bytes, String source)`
`ByteArrayStream(byte[] bytes, String source, String contentType)`

## Method Summary

Modifier and Type
Method
Description
`InputStream`
`getStream()`
Get an open stream.

### Methods inherited from class org.apache.solr.common.util.ContentStreamBase

`attemptToDetermineContentType, create, getCharsetFromContentType, getContentType, getName, getReader, getSize, getSourceInfo, setContentType, setName, setSize, setSourceInfo`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### ByteArrayStream

public ByteArrayStream(byte[] bytes, String source)

### ByteArrayStream

public ByteArrayStream(byte[] bytes, String source, String contentType)

## Method Details

### getStream

public InputStream getStream() throws IOException
Description copied from interface: `ContentStream`
Get an open stream. You are responsible for closing it. Consider using something like:

       InputStream stream = stream.getStream();
       try {
         // use the stream...
       }
       finally {
         IOUtils.closeQuietly(stream);
       }

Only the first call to `getStream()` or `getReader()` is guaranteed to work. The runtime behavior for additional calls is undefined.

Note: you must call `getStream()` or `getReader()` before the attributes (name, contentType, etc.) are guaranteed to be set. Streams may be lazy loaded only when this method is called.

Throws:
  `IOException`