This class is an abstraction of a random access file.
Each file contains a magic header, and reading / writing is done in blocks.
See also {@link SecureFileStore}
| Methods |
| static FileStore |
open(DataHandler handler, String name, String mode)
Open a non encrypted file store with the given settings.
|
| static FileStore |
open(DataHandler handler, String name, String mode)
Open a non encrypted file store with the given settings.
Parameters:
handler - the data handler
name - the file name
mode - the access mode (r, rw, rws, rwd)
Returns:
the created object
|
| static FileStore |
open(DataHandler handler, String name, String mode, String cipher, byte[] key)
Open an encrypted file store with the given settings.
|
| static FileStore |
open(DataHandler handler, String name, String mode, String cipher, byte[] key)
Open an encrypted file store with the given settings.
Parameters:
handler - the data handler
name - the file name
mode - the access mode (r, rw, rws, rwd)
cipher - the name of the cipher algorithm
key - the encryption key
Returns:
the created object
|
| static FileStore |
open(DataHandler handler, String name, String mode, String cipher, byte[] key, int keyIterations)
Open an encrypted file store with the given settings.
|
| static FileStore |
open(DataHandler handler, String name, String mode, String cipher, byte[] key, int keyIterations)
Open an encrypted file store with the given settings.
Parameters:
handler - the data handler
name - the file name
mode - the access mode (r, rw, rws, rwd)
cipher - the name of the cipher algorithm
key - the encryption key
keyIterations - the number of iterations the key should be hashed
Returns:
the created object
|
|
FileStore(DataHandler handler, String name, String mode)
Create a new file using the given settings.
|
|
FileStore(DataHandler handler, String name, String mode)
Create a new file using the given settings.
Parameters:
handler - the callback object
name - the file name
mode - the access mode ("r", "rw", "rws", "rwd")
|
| void |
autoDelete()
Automatically delete the file once it is no longer in use.
|
| void |
autoDelete()
Automatically delete the file once it is no longer in use.
|
| void |
close()
Close the file.
|
| void |
close()
Close the file.
|
| void |
closeAndDeleteSilently()
Close the file (ignoring exceptions) and delete the file.
|
| void |
closeAndDeleteSilently()
Close the file (ignoring exceptions) and delete the file.
|
| void |
closeFile()
Close the file.
|
| void |
closeFile() throws IOException
Close the file. The file may later be re-opened using openFile.
|
| void |
closeSilently()
Close the file without throwing any exceptions.
|
| void |
closeSilently()
Close the file without throwing any exceptions. Exceptions are simply
ignored.
|
| byte[] |
generateSalt()
Generate the random salt bytes if required.
|
| byte[] |
generateSalt()
Generate the random salt bytes if required.
Returns:
the random salt or the magic
|
| long |
getFilePointer()
Get the current location of the file pointer.
|
| long |
getFilePointer()
Get the current location of the file pointer.
Returns:
the location
|
| void |
init()
Initialize the file.
|
| void |
init()
Initialize the file. This method will write or check the file header if
required.
|
| void |
initKey(byte[] salt)
Initialize the key using the given salt.
|
| void |
initKey(byte[] salt)
Initialize the key using the given salt.
Parameters:
salt - the salt
|
| long |
length()
Get the file size in bytes.
|
| long |
length()
Get the file size in bytes.
Returns:
the file size
|
| void |
openFile()
Re-open the file.
|
| void |
openFile() throws IOException
Re-open the file. The file pointer will be reset to the previous
location.
|
| void |
readFully(byte[] b, int off, int len)
Read a number of bytes.
|
| void |
readFully(byte[] b, int off, int len)
Read a number of bytes.
Parameters:
b - the target buffer
off - the offset
len - the number of bytes to read
|
| void |
readFullyDirect(byte[] b, int off, int len)
Read a number of bytes without decrypting.
|
| void |
readFullyDirect(byte[] b, int off, int len)
Read a number of bytes without decrypting.
Parameters:
b - the target buffer
off - the offset
len - the number of bytes to read
|
| void |
releaseLock()
Release the file lock.
|
| void |
releaseLock()
Release the file lock.
|
| void |
seek(long pos)
Go to the specified file location.
|
| void |
seek(long pos)
Go to the specified file location.
Parameters:
pos - the location
|
| void |
setCheckedWriting(boolean value)
|
| void |
setCheckedWriting(boolean value)
|
| void |
setLength(long newLength)
Set the length of the file.
|
| void |
setLength(long newLength)
Set the length of the file. This will expand or shrink the file.
Parameters:
newLength - the new file size
|
| void |
stopAutoDelete()
No longer automatically delete the file once it is no longer in use.
|
| void |
stopAutoDelete()
No longer automatically delete the file once it is no longer in use.
|
| void |
sync()
Call fsync.
|
| void |
sync()
Call fsync. Depending on the operating system and hardware, this may or
may not in fact write the changes.
|
| boolean |
tryLock()
Try to lock the file.
|
| boolean |
tryLock()
Try to lock the file.
Returns:
true if successful
|
| void |
write(byte[] b, int off, int len)
Write a number of bytes.
|
| void |
write(byte[] b, int off, int len)
Write a number of bytes.
Parameters:
b - the source buffer
off - the offset
len - the number of bytes to write
|
| void |
writeDirect(byte[] b, int off, int len)
Write a number of bytes without encrypting.
|
| void |
writeDirect(byte[] b, int off, int len)
Write a number of bytes without encrypting.
Parameters:
b - the source buffer
off - the offset
len - the number of bytes to write
|
The size of the file header in bytes.
The file name.