Package com.gengoai.io.resource
Class ByteArrayResource
- java.lang.Object
-
- com.gengoai.io.resource.BaseResource
-
- com.gengoai.io.resource.ByteArrayResource
-
- All Implemented Interfaces:
NonTraversableResource
,Resource
,Serializable
public class ByteArrayResource extends BaseResource implements NonTraversableResource
A Resource that wraps a byte array.- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.gengoai.io.resource.Resource
Resource.Deserializer
-
-
Field Summary
-
Fields inherited from interface com.gengoai.io.resource.Resource
ALL_FILE_PATTERN
-
-
Constructor Summary
Constructors Constructor Description ByteArrayResource()
Instantiates a new Byte array resource.ByteArrayResource(byte[] b)
Instantiates a new Byte array resource.ByteArrayResource(byte[] b, int offset, int len)
Instantiates a new Byte array resource.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Resource
append(byte[] byteArray)
Appends the given byte array content to the resource.protected InputStream
createInputStream()
Create input stream input stream.protected OutputStream
createOutputStream()
Create output stream output stream.boolean
equals(Object o)
boolean
exists()
Exists boolean.int
hashCode()
MStream<String>
lines()
Creates anMStream
over the lines in the resource.-
Methods inherited from class com.gengoai.io.resource.BaseResource
asFile, asURI, baseName, canRead, canWrite, compressed, descriptor, getCharset, inputStream, isCompressed, isDirectory, outputStream, path, setCharset, setCompression, setIsCompressed, toString, uncompressed
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.gengoai.io.resource.NonTraversableResource
childIterator, childIterator, getChild, getChildren, getChildren, getChildren, getChildren, getChildren, getParent
-
Methods inherited from interface com.gengoai.io.resource.Resource
append, asFile, asPath, asURI, asURL, baseName, canRead, canWrite, compressed, copy, delete, delete, deleteOnExit, descriptor, forEach, getCharset, inputStream, isCompressed, isDirectory, mkdir, mkdirs, outputStream, path, readBytes, reader, readLines, readObject, readToString, setCharset, setCompression, setIsCompressed, uncompressed, write, write, writeObject, writer
-
-
-
-
Constructor Detail
-
ByteArrayResource
public ByteArrayResource()
Instantiates a new Byte array resource.
-
ByteArrayResource
public ByteArrayResource(byte[] b)
Instantiates a new Byte array resource.- Parameters:
b
- an initial byte array
-
ByteArrayResource
public ByteArrayResource(byte[] b, int offset, int len)
Instantiates a new Byte array resource.- Parameters:
b
- an initial byte arrayoffset
- the offset into the byte arraylen
- the number of bytes to copy
-
-
Method Detail
-
append
public Resource append(byte[] byteArray) throws IOException
Description copied from interface:Resource
Appends the given byte array content to the resource.
- Specified by:
append
in interfaceResource
- Parameters:
byteArray
- The content to append- Returns:
- the resource
- Throws:
IOException
- the io exception
-
exists
public boolean exists()
Description copied from interface:Resource
Exists boolean.
-
lines
public MStream<String> lines() throws IOException
Description copied from interface:Resource
Creates anMStream
over the lines in the resource.- Specified by:
lines
in interfaceResource
- Returns:
- the stream of lines
- Throws:
IOException
- Something went wrong reading from the resource
-
createInputStream
protected InputStream createInputStream() throws IOException
Description copied from class:BaseResource
Create input stream input stream.- Overrides:
createInputStream
in classBaseResource
- Returns:
- the input stream
- Throws:
IOException
- the io exception
-
createOutputStream
protected OutputStream createOutputStream() throws IOException
Description copied from class:BaseResource
Create output stream output stream.- Overrides:
createOutputStream
in classBaseResource
- Returns:
- the output stream
- Throws:
IOException
- the io exception
-
-