public class LocalStorage extends AbstractBean
ApplicationContext.getLocalStorage()
,
SessionStorage
Modifier | Constructor and Description |
---|---|
protected |
LocalStorage(ApplicationContext context) |
Modifier and Type | Method and Description |
---|---|
boolean |
deleteFile(String fileName)
Deletes the entry specified by the
name parameter. |
protected ApplicationContext |
getContext() |
File |
getDirectory()
Returns the directory where the local storage is located
|
long |
getStorageLimit()
Gets the limit of the local storage
|
Object |
load(String fileName)
Loads the been from the local storage
|
InputStream |
openInputFile(String fileName)
Opens an input stream to read from the entry
specified by the
name parameter. |
OutputStream |
openOutputFile(String fileName)
Opens an output stream to write to the entry
specified by the
name parameter. |
OutputStream |
openOutputFile(String fileName,
boolean append)
Opens an output stream to write to the entry
specified by the
name parameter. |
void |
save(Object bean,
String fileName)
Saves the
bean to the local storage |
void |
setDirectory(File directory)
Sets the location of the local storage
|
void |
setStorageLimit(long storageLimit)
Sets the limit of the lical storage
|
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
protected LocalStorage(ApplicationContext context)
protected final ApplicationContext getContext()
public InputStream openInputFile(String fileName) throws IOException
name
parameter.
If the named entry cannot be opened for reading
then a IOException
is thrown.fileName
- the storage-dependent nameInputStream
objectIOException
- if the specified name is invalid,
or an input stream cannot be openedpublic OutputStream openOutputFile(String fileName) throws IOException
name
parameter.
If the named entry cannot be opened for writing
then a IOException
is thrown.
If the named entry does not exist it can be created.
The entry will be recreated if already exists.fileName
- the storage-dependent nameOutputStream
objectIOException
- if the specified name is invalid,
or an output stream cannot be openedpublic OutputStream openOutputFile(String fileName, boolean append) throws IOException
name
parameter.
If the named entry cannot be opened for writing
then a IOException
is thrown.
If the named entry does not exist it can be created.
You can decide whether data will be appended via append parameter.fileName
- the storage-dependent nameappend
- if true
, then bytes will be written
to the end of the output entry rather than the beginningOutputStream
objectIOException
- if the specified name is invalid,
or an output stream cannot be openedpublic boolean deleteFile(String fileName) throws IOException
name
parameter.fileName
- the storage-dependent nameIOException
- if the specified name is invalid,
or an internal entry cannot be deletedpublic void save(Object bean, String fileName) throws IOException
bean
to the local storagebean
- the object ot be savedfileName
- the targen file nameIOException
public Object load(String fileName) throws IOException
fileName
- name of the file to be read fromIOException
public long getStorageLimit()
public void setStorageLimit(long storageLimit)
storageLimit
- the limit of the lical storagepublic File getDirectory()
public void setDirectory(File directory)
directory
- the location of the local storageCopyright © 2009–2014. All rights reserved.