@NotStorableClass public class FileForStorable extends Object implements IFileForStorable
Modifier and Type | Field and Description |
---|---|
protected static String |
FAILED_DELETE_FILE |
protected static String |
FILE_ALREADY_CLOSED |
protected static String |
FILE_NOT_OPENNED |
protected JoafipLogger |
logger |
protected IRandomAccessFile |
randomAccessFile
for random read write file access
|
Constructor and Description |
---|
FileForStorable(FileAccessParameter fileAccessParameter)
create a file to read from and write to
IFileStorable object |
Modifier and Type | Method and Description |
---|---|
void |
close()
close heap file access operation
|
protected HeapException |
closeAfterIOException(String message,
FileIOException exception)
close after io exception
|
void |
copy(FileForStorable fileForStorable)
copy this file to an other file
|
void |
copy(String fileName)
copy this file to an other file
|
void |
deleteFileIfExists()
delete file if exists
|
void |
deleteFileIfExistsRenaming()
delete file if exists
|
void |
flush()
flush modification to disk
|
int |
getCachePageSize() |
File |
getFile() |
long |
getFileSize()
Returns the size of this file.
|
boolean |
isOpened() |
boolean |
isUseCache() |
void |
open()
open heap file for access operation
|
int |
read(byte[] data)
delegate to
RandomAccessFile.read(byte[]) closing the file in
case of I/O errorReads up to data.length bytes of data from this file into an
array of bytes. |
int |
read(byte[] data,
int offset,
int length) |
void |
resetFileSize() |
void |
seek(long positionInFile)
delegate to
RandomAccessFile.seek(long) closing the file in case
of I/O error |
void |
setFileSize(long newSize)
set the size of this file
|
String |
toString() |
void |
write(byte[] data)
delegate to
RandomAccessFile#write(byte[])) closing the file in
case of I/O error |
void |
write(byte[] data,
int offset,
int length) |
void |
write(ToBackupRecord toBackupRecord) |
protected final JoafipLogger logger
protected static final String FILE_ALREADY_CLOSED
protected static final String FILE_NOT_OPENNED
protected static final String FAILED_DELETE_FILE
protected IRandomAccessFile randomAccessFile
public FileForStorable(FileAccessParameter fileAccessParameter) throws HeapException
IFileStorable
objectfileAccessParameter
- HeapException
public boolean isUseCache()
isUseCache
in interface IFileForStorable
public int getCachePageSize()
getCachePageSize
in interface IFileForStorable
public void open() throws HeapException
IFileForStorable
open
in interface IFileForStorable
HeapException
- if an I/O error occurs while opening filepublic void close() throws HeapException
IFileForStorable
close
in interface IFileForStorable
HeapException
- if an I/O error occurs while closing the the filepublic void flush() throws HeapException
IFileForStorable
flush
in interface IFileForStorable
HeapException
public void resetFileSize() throws HeapException
resetFileSize
in interface IFileForStorable
HeapException
public void deleteFileIfExists() throws HeapException
IFileForStorable
deleteFileIfExists
in interface IFileForStorable
HeapException
public void deleteFileIfExistsRenaming() throws HeapException
IFileForStorable
deleteFileIfExistsRenaming
in interface IFileForStorable
HeapException
public boolean isOpened()
public void seek(long positionInFile) throws HeapException
IFileForStorable
RandomAccessFile.seek(long)
closing the file in case
of I/O errorseek
in interface IFileForStorable
HeapException
- if an I/O error occurspublic int read(byte[] data) throws HeapException
IFileForStorable
RandomAccessFile.read(byte[])
closing the file in
case of I/O errordata.length
bytes of data from this file into an
array of bytes.read
in interface IFileForStorable
data
- where store data readHeapException
- if an I/O error occurspublic int read(byte[] data, int offset, int length) throws HeapException
read
in interface IFileForStorable
HeapException
public void write(byte[] data) throws HeapException
IFileForStorable
RandomAccessFile#write(byte[]))
closing the file in
case of I/O errorwrite
in interface IFileForStorable
HeapException
- if an I/O error occurspublic void write(byte[] data, int offset, int length) throws HeapException
write
in interface IFileForStorable
HeapException
public void write(ToBackupRecord toBackupRecord) throws HeapException
write
in interface IFileForStorable
HeapException
public File getFile()
getFile
in interface IFileForStorable
public long getFileSize() throws HeapException
IFileForStorable
getFileSize
in interface IFileForStorable
HeapException
- if an I/O error occurs.public void setFileSize(long newSize) throws HeapException
newSize
- the file new sizeHeapException
- if an I/O error occurs.public void copy(FileForStorable fileForStorable) throws HeapException
IFileForStorable
copy
in interface IFileForStorable
HeapException
public void copy(String fileName) throws FileIOException
IFileForStorable
copy
in interface IFileForStorable
FileIOException
protected HeapException closeAfterIOException(String message, FileIOException exception) throws HeapException
HeapException
Copyright © 2007-2012 Luc Peuvrier. All Rights Reserved.