Class DiskStore

java.lang.Object
org.ghost4j.util.DiskStore

public class DiskStore extends Object
Singleton class used to store and retrieve files to / from a temporary disk storage.
  • Field Details

    • ROOT_PATH

      public static final String ROOT_PATH
    • instance

      private static DiskStore instance
      Shared instance.
    • map

      private final Map<String,File> map
      Map used to store references to temprorary files.
  • Constructor Details

    • DiskStore

      private DiskStore()
      Private constructor.
  • Method Details

    • getInstance

      public static DiskStore getInstance()
      Access to the shared instance.
      Returns:
      The shared DiskStore instance.
    • generateUniqueKey

      public String generateUniqueKey()
      Generates a unique diskstore key. Use the JVM PID and UUID.
      Returns:
      A unique key as string
    • getFile

      public File getFile(String key)
      Retrieve a File from a store key. If key is unknown, null is returned.
      Parameters:
      key - Unique file resource identifier.
      Returns:
      File or null (if not found).
    • removeFile

      public void removeFile(String key) throws IOException
      Remove a file from the store. This also deleted the temporary file from the file system.
      Parameters:
      key - Unique file resource identifier.
      Throws:
      IOException - In case the file cannot be deleted.
    • addFile

      public File addFile(String key)
      Add a file to the store.
      Parameters:
      key - File unique identifier.
      Returns:
      The generated (empty) file.