public class EncodedImageSource
extends java.lang.Object
implements java.io.Closeable
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the underlying
InputStream if the EncodedImageSource owns it. |
static EncodedImageSource |
from(byte[] bytes)
Creates an
EncodedImageSource for the given byte array. |
static EncodedImageSource |
from(java.io.File file)
Creates an
EncodedImageSource for the given file. |
static EncodedImageSource |
from(java.io.InputStream inputStream)
Creates an
EncodedImageSource for the given InputStream. |
static EncodedImageSource |
from(java.lang.String filePath)
Creates an
EncodedImageSource for the given file. |
java.io.InputStream |
getInputStream()
Returns the underlying
InputStream |
java.lang.String |
toString() |
public static EncodedImageSource from(java.io.File file) throws java.io.FileNotFoundException
EncodedImageSource for the given file.file - The file to read fromjava.io.FileNotFoundException - If the file does not existspublic static EncodedImageSource from(java.lang.String filePath) throws java.io.FileNotFoundException
EncodedImageSource for the given file.filePath - The file to read fromjava.io.FileNotFoundException - If the file does not exists or is not readablepublic static EncodedImageSource from(byte[] bytes)
EncodedImageSource for the given byte array.bytes - Array containing the encoded imagepublic static EncodedImageSource from(java.io.InputStream inputStream)
EncodedImageSource for the given InputStream.inputStream - Input stream to read from; the caller keeps ownership of the InputStream and is responsible to properly close it.public java.io.InputStream getInputStream()
InputStreampublic void close()
throws java.io.IOException
InputStream if the EncodedImageSource owns it.close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object