Constructor and Description |
---|
FileByteStore()
Constructs a new FileByteStore which uses a temporary file as
backing store.
|
FileByteStore(File file)
Constructs a new FileByteStore which uses the given file as a
backing store.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Tidies up.
|
static void |
copy(File file,
OutputStream out)
Utility method to copy the contents of a file to an output stream.
|
void |
copy(OutputStream out)
Takes all the data written so far into this store's sink stream
and copies it to a destination stream.
|
File |
getFile()
Returns the file used by this store.
|
long |
getLength()
Returns the number of bytes currently stored in this object.
|
OutputStream |
getOutputStream()
Returns an output stream which can be used to write to the store.
|
ByteBuffer[] |
toByteBuffers()
Returns an array of byte buffers containing the bytes written
to this store.
|
static ByteBuffer[] |
toByteBuffers(File file)
Returns a read-only ByteBuffer array representing the contents
of a file, with default maximum buffer length.
|
public FileByteStore(File file) throws IOException
file
- location of the backing file which will be usedIOException
- if there is some I/O-related problem with
opening the fileSecurityException
- if the current security context does not
allow writing to a temporary filepublic FileByteStore() throws IOException
java.io.tmpdir
system property.IOException
- if there is some I/O-related problem with
opening the fileSecurityException
- if the current security context does not
allow writing to a temporary filepublic File getFile()
public OutputStream getOutputStream()
ByteStore
BufferedOutputStream
for efficiency if required.getOutputStream
in interface ByteStore
public long getLength()
ByteStore
public void copy(OutputStream out) throws IOException
ByteStore
copy
in interface ByteStore
out
- data destination streamIOException
public ByteBuffer[] toByteBuffers() throws IOException
ByteStore
Integer.MAX_VALUE
, more than one will be
required. The limit of each buffer indicates the
number of bytes it contains.
Usual usage will be to write all data, then call this method once; this model may affect implementation decisions about efficiency.
toByteBuffers
in interface ByteStore
IOException
- if there is an I/O errorpublic static void copy(File file, OutputStream out) throws IOException
file
- fileout
- destination streamIOException
public static ByteBuffer[] toByteBuffers(File file) throws IOException
file
- fileIOException
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.