Class LocalStorage

java.lang.Object
org.jdesktop.application.AbstractBean
org.jdesktop.application.LocalStorage

public class LocalStorage extends AbstractBean
Access to per application, per user, local file storage.
Author:
Hans Muller (Hans.Muller@Sun.COM)
See Also:
  • Constructor Details

  • Method Details

    • getContext

      protected final ApplicationContext getContext()
    • openInputFile

      public InputStream openInputFile(String fileName) throws IOException
      Opens an input stream to read from the entry specified by the name parameter. If the named entry cannot be opened for reading then a IOException is thrown.
      Parameters:
      fileName - the storage-dependent name
      Returns:
      an InputStream object
      Throws:
      IOException - if the specified name is invalid, or an input stream cannot be opened
    • openOutputFile

      public OutputStream openOutputFile(String fileName) throws IOException
      Opens an output stream to write to the entry specified by the 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.
      Parameters:
      fileName - the storage-dependent name
      Returns:
      an OutputStream object
      Throws:
      IOException - if the specified name is invalid, or an output stream cannot be opened
    • openOutputFile

      public OutputStream openOutputFile(String fileName, boolean append) throws IOException
      Opens an output stream to write to the entry specified by the 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.
      Parameters:
      fileName - the storage-dependent name
      append - if true, then bytes will be written to the end of the output entry rather than the beginning
      Returns:
      an OutputStream object
      Throws:
      IOException - if the specified name is invalid, or an output stream cannot be opened
    • deleteFile

      public boolean deleteFile(String fileName) throws IOException
      Deletes the entry specified by the name parameter.
      Parameters:
      fileName - the storage-dependent name
      Throws:
      IOException - if the specified name is invalid, or an internal entry cannot be deleted
    • save

      public void save(Object bean, String fileName) throws IOException
      Saves the bean to the local storage
      Parameters:
      bean - the object ot be saved
      fileName - the targen file name
      Throws:
      IOException
    • load

      public Object load(String fileName) throws IOException
      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

      public File getDirectory()
      Returns the directory where the local storage is located
      Returns:
      the directory where the local storage is located
    • setDirectory

      public void setDirectory(File directory)
      Sets the location of the local storage
      Parameters:
      directory - the location of the local storage