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()throwsUncheckedIOExceptioninstead ofIOException.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)FilegetFile()Gets the File.Optional<String>getFileName()Gets the file name of the source.inthashCode()ArrayByteSourceload()Loads the content of the byte source into memory.org.joda.beans.MetaBeanmetaBean()static FileByteSourceof(File file)Creates an instance based on the underlying file.static FileByteSourceof(Path path)Creates an instance based on a file path.InputStreamopenStream()longsize()Gets the size of the byte source, throwing an unchecked exception.Optional<Long>sizeIfKnown()StringtoString()-
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:
metaBeanin interfaceorg.joda.beans.Bean
-
getFileName
public Optional<String> getFileName()
Description copied from class:BeanByteSourceGets the file name of the source.Most sources originate from a file-based location. This is captured and returned here where available.
- Overrides:
getFileNamein 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:
openStreamin classByteSource- Throws:
IOException
-
sizeIfKnown
public Optional<Long> sizeIfKnown()
- Overrides:
sizeIfKnownin classByteSource
-
size
public long size()
Description copied from class:BeanByteSourceGets the size of the byte source, throwing an unchecked exception.This overrides
ByteSourceto throwUncheckedIOExceptioninstead ofIOException.- Overrides:
sizein classBeanByteSource
-
load
public ArrayByteSource load()
Description copied from class:BeanByteSourceLoads the content of the byte source into memory.- Overrides:
loadin classBeanByteSource- Returns:
- the byte array
-
-