Class FileAsset

  • All Implemented Interfaces:
    Asset

    public class FileAsset
    extends java.lang.Object
    implements Asset
    Implementation of an Asset backed by a File
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.File file  
    • Constructor Summary

      Constructors 
      Constructor Description
      FileAsset​(java.io.File file)
      Load the specified File.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.io.File getSource()
      Returns the loaded file.
      java.io.InputStream openStream()
      Opens a new FileInputStream for the given File.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • file

        private java.io.File file
    • Constructor Detail

      • FileAsset

        public FileAsset​(java.io.File file)
        Load the specified File.
        Parameters:
        file - The file to load
        Throws:
        java.lang.IllegalArgumentException - File can not be null
        java.lang.IllegalArgumentException - File must exist
    • Method Detail

      • openStream

        public java.io.InputStream openStream()
        Opens a new FileInputStream for the given File. Can throw a Runtime exception if the file has been deleted in between the FileResource was created and the stream is opened.
        Specified by:
        openStream in interface Asset
        Returns:
        A new open InputStream for each call
        Throws:
        java.lang.RuntimeException - If the file is not found.
      • getSource

        public java.io.File getSource()
        Returns the loaded file.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()