Package com.opengamma.strata.collect.io
Class FileByteSource
- java.lang.Object
-
- com.google.common.io.ByteSource
-
- com.opengamma.strata.collect.io.BeanByteSource
-
- com.opengamma.strata.collect.io.FileByteSource
-
- All Implemented Interfaces:
Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class FileByteSource extends BeanByteSource implements org.joda.beans.ImmutableBean, Serializable
A byte source implementation that obtains data from a file.This implementation differs from Guava in that it is a Joda-Bean. In addition,
BeanByteSource.read()
throwsUncheckedIOException
instead ofIOException
.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object other)
File
getFile()
Gets the File.Optional<String>
getFileName()
Gets the file name of the source.int
hashCode()
ArrayByteSource
load()
Loads the content of the byte source into memory.org.joda.beans.MetaBean
metaBean()
static FileByteSource
of(File file)
Creates an instance based on the underlying file.static FileByteSource
of(Path path)
Creates an instance based on a file path.InputStream
openStream()
long
size()
Gets the size of the byte source, throwing an unchecked exception.Optional<Long>
sizeIfKnown()
String
toString()
-
Methods inherited from class com.opengamma.strata.collect.io.BeanByteSource
asCharSource, asCharSourceUtf8, asCharSourceUtf8UsingBom, getFileNameOrThrow, hash, isEmpty, read, readUtf8, readUtf8UsingBom, toBase64, toBase64String, toHash, toHashString
-
Methods inherited from class com.google.common.io.ByteSource
concat, concat, concat, contentEquals, copyTo, copyTo, empty, openBufferedStream, read, slice, wrap
-
-
-
-
Method Detail
-
of
public static FileByteSource of(File file)
Creates an instance based on the underlying file.- Parameters:
file
- the file- Returns:
- the byte source
-
of
public static FileByteSource of(Path path)
Creates an instance based on a file path.- Parameters:
path
- the path to a file- Returns:
- the byte source
-
metaBean
public org.joda.beans.MetaBean metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getFileName
public Optional<String> getFileName()
Description copied from class:BeanByteSource
Gets the file name of the source.Most sources originate from a file-based location. This is captured and returned here where available.
- Overrides:
getFileName
in classBeanByteSource
- Returns:
- the file name, empty if not known
-
getFile
public File getFile()
Gets the File.- Returns:
- the File
-
openStream
public InputStream openStream() throws IOException
- Specified by:
openStream
in classByteSource
- Throws:
IOException
-
sizeIfKnown
public Optional<Long> sizeIfKnown()
- Overrides:
sizeIfKnown
in classByteSource
-
size
public long size()
Description copied from class:BeanByteSource
Gets the size of the byte source, throwing an unchecked exception.This overrides
ByteSource
to throwUncheckedIOException
instead ofIOException
.- Overrides:
size
in classBeanByteSource
-
load
public ArrayByteSource load()
Description copied from class:BeanByteSource
Loads the content of the byte source into memory.- Overrides:
load
in classBeanByteSource
- Returns:
- the byte array
-
-