Package org.jdesktop.application
Class LocalStorage
java.lang.Object
org.jdesktop.application.AbstractBean
org.jdesktop.application.LocalStorage
Access to per application, per user, local file storage.
- Author:
- Hans Muller (Hans.Muller@Sun.COM)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandeleteFile(String fileName) Deletes the entry specified by thenameparameter.protected final ApplicationContextReturns the directory where the local storage is locatedlongGets the limit of the local storageLoads the been from the local storageopenInputFile(String fileName) Opens an input stream to read from the entry specified by thenameparameter.openOutputFile(String fileName) Opens an output stream to write to the entry specified by thenameparameter.openOutputFile(String fileName, boolean append) Opens an output stream to write to the entry specified by thenameparameter.voidSaves thebeanto the local storagevoidsetDirectory(File directory) Sets the location of the local storagevoidsetStorageLimit(long storageLimit) Sets the limit of the lical storageMethods inherited from class org.jdesktop.application.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Constructor Details
-
LocalStorage
-
-
Method Details
-
getContext
-
openInputFile
Opens an input stream to read from the entry specified by thenameparameter. If the named entry cannot be opened for reading then aIOExceptionis thrown.- Parameters:
fileName- the storage-dependent name- Returns:
- an
InputStreamobject - Throws:
IOException- if the specified name is invalid, or an input stream cannot be opened
-
openOutputFile
Opens an output stream to write to the entry specified by thenameparameter. If the named entry cannot be opened for writing then aIOExceptionis thrown. If the named entry does not exist it can be created. The entry will be recreated if already exists.- Parameters:
fileName- the storage-dependent name- Returns:
- an
OutputStreamobject - Throws:
IOException- if the specified name is invalid, or an output stream cannot be opened
-
openOutputFile
Opens an output stream to write to the entry specified by thenameparameter. If the named entry cannot be opened for writing then aIOExceptionis thrown. If the named entry does not exist it can be created. You can decide whether data will be appended via append parameter.- Parameters:
fileName- the storage-dependent nameappend- iftrue, then bytes will be written to the end of the output entry rather than the beginning- Returns:
- an
OutputStreamobject - Throws:
IOException- if the specified name is invalid, or an output stream cannot be opened
-
deleteFile
Deletes the entry specified by thenameparameter.- Parameters:
fileName- the storage-dependent name- Throws:
IOException- if the specified name is invalid, or an internal entry cannot be deleted
-
save
Saves thebeanto the local storage- Parameters:
bean- the object ot be savedfileName- the targen file name- Throws:
IOException
-
load
Loads the been from the local storage- Parameters:
fileName- name of the file to be read from- Returns:
- loaded object
- Throws:
IOException
-
getStorageLimit
public long getStorageLimit()Gets the limit of the local storage- Returns:
- the limit of the local storage
-
setStorageLimit
public void setStorageLimit(long storageLimit) Sets the limit of the lical storage- Parameters:
storageLimit- the limit of the lical storage
-
getDirectory
Returns the directory where the local storage is located- Returns:
- the directory where the local storage is located
-
setDirectory
Sets the location of the local storage- Parameters:
directory- the location of the local storage
-