public final class ContentStreamUtils extends Object
ContentStream objects.| Modifier and Type | Class and Description |
|---|---|
static class |
ContentStreamUtils.AutoCloseInputStream
InputStream that gets closed when the end of the stream is reached or the
underlying stream throws an exception.
|
| Modifier and Type | Method and Description |
|---|---|
static MutableContentStream |
createByteArrayContentStream(String filename,
byte[] contentBytes)
Creates a content stream object from a byte array.
|
static MutableContentStream |
createByteArrayContentStream(String filename,
byte[] contentBytes,
int offset,
int length,
String mimetype)
Creates a content stream object from a byte array.
|
static MutableContentStream |
createByteArrayContentStream(String filename,
byte[] contentBytes,
String mimetype)
Creates a content stream object from a byte array.
|
static MutableContentStream |
createContentStream(String filename,
BigInteger length,
String mimetype,
InputStream stream)
Creates a content stream object for an InputStream.
|
static MutableContentStream |
createContentStream(String filename,
long length,
String mimetype,
InputStream stream)
Creates a content stream object for an InputStream.
|
static MutableContentStream |
createFileContentStream(File file)
Creates a content stream object from file.
|
static MutableContentStream |
createFileContentStream(File file,
String mimetype)
Creates a content stream object from file.
|
static MutableContentStream |
createFileContentStream(String filename,
File file)
Creates a content stream object from file.
|
static MutableContentStream |
createFileContentStream(String filename,
File file,
String mimetype)
Creates a content stream object from file.
|
static MutableContentStream |
createTextContentStream(String filename,
String content)
Creates a content stream object from a string.
|
static MutableContentStream |
createTextContentStream(String filename,
String content,
String mimetype)
Creates a content stream object from a string.
|
static void |
writeContentStreamToFile(ContentStream contentStream,
File file)
Writes a content stream to a file.
|
static void |
writeContentStreamToOutputStream(ContentStream contentStream,
OutputStream outputStream)
Writes a content stream to an output stream.
|
public static MutableContentStream createContentStream(String filename, long length, String mimetype, InputStream stream)
filename - name of the content streamlength - length of the stream in bytesmimetype - content MIME typestream - the InputStreamMutableContentStream objectpublic static MutableContentStream createContentStream(String filename, BigInteger length, String mimetype, InputStream stream)
filename - name of the content streamlength - length of the stream in bytesmimetype - content MIME typestream - the InputStreamMutableContentStream objectpublic static MutableContentStream createByteArrayContentStream(String filename, byte[] contentBytes)
filename - name of the content streamcontentBytes - content bytesMutableContentStream objectpublic static MutableContentStream createByteArrayContentStream(String filename, byte[] contentBytes, String mimetype)
filename - name of the content streamcontentBytes - the content bytesmimetype - content MIME typeMutableContentStream objectpublic static MutableContentStream createByteArrayContentStream(String filename, byte[] contentBytes, int offset, int length, String mimetype)
filename - name of the content streamcontentBytes - the content bytesoffset - the offset in the content byteslength - the maximum number of bytes to read from the content bytesmimetype - content MIME typeMutableContentStream objectpublic static MutableContentStream createTextContentStream(String filename, String content)
filename - name of the content streamcontent - the content stringMutableContentStream objectpublic static MutableContentStream createTextContentStream(String filename, String content, String mimetype)
filename - name of the content streamcontent - the content stringmimetype - content MIME typeMutableContentStream objectpublic static MutableContentStream createFileContentStream(File file) throws FileNotFoundException
file - the fileMutableContentStream objectFileNotFoundExceptionpublic static MutableContentStream createFileContentStream(String filename, File file) throws FileNotFoundException
filename - name of the content streamfile - the fileMutableContentStream objectFileNotFoundExceptionpublic static MutableContentStream createFileContentStream(File file, String mimetype) throws FileNotFoundException
file - the filemimetype - content MIME typeMutableContentStream objectFileNotFoundExceptionpublic static MutableContentStream createFileContentStream(String filename, File file, String mimetype) throws FileNotFoundException
filename - name of the content streamfile - the filemimetype - content MIME typeMutableContentStream objectFileNotFoundExceptionpublic static void writeContentStreamToOutputStream(ContentStream contentStream, OutputStream outputStream) throws IOException
null or the stream itself is
null, nothing is written to the output stream. The content stream
is closed at the end. The output stream remains open.contentStream - the content stream, may be nulloutputStream - the output stream, not nullIOExceptionpublic static void writeContentStreamToFile(ContentStream contentStream, File file) throws IOException
null or the stream itself is
null, the file is empty. The content stream and the file are
closed at the end.contentStream - the content stream, may be nullfile - the file, not nullIOExceptionCopyright © 2009–2017 The Apache Software Foundation. All rights reserved.