Class FileUtils


  • public class FileUtils
    extends java.lang.Object
    Utils for handling files
    • Constructor Summary

      Constructors 
      Constructor Description
      FileUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.ClassLoader classLoader()
      Get current class loader
      static byte[] resourceAsByteArray​(java.lang.String path)
      Get classpath resource as byte array
      static java.util.Optional<java.io.File> resourceAsFile​(java.lang.String name)
      Get classpath resource as file
      static java.util.Optional<java.io.InputStream> resourceAsStream​(java.lang.String name)
      Get classpath resource as file
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileUtils

        public FileUtils()
    • Method Detail

      • resourceAsByteArray

        public static byte[] resourceAsByteArray​(java.lang.String path)
                                          throws java.io.IOException
        Get classpath resource as byte array
        Parameters:
        path - the path of the resource
        Returns:
        the byte array of the resource
        Throws:
        java.io.IOException - if the resource cannot be read
      • resourceAsFile

        public static java.util.Optional<java.io.File> resourceAsFile​(java.lang.String name)
        Get classpath resource as file
        Parameters:
        name - the name of the resource
        Returns:
        the resource file, or Optional.EMPTY
      • resourceAsStream

        public static java.util.Optional<java.io.InputStream> resourceAsStream​(java.lang.String name)
        Get classpath resource as file
        Parameters:
        name - the name of the resource
        Returns:
        the resource file, or Optional.EMPTY
      • classLoader

        public static java.lang.ClassLoader classLoader()
        Get current class loader
        Returns:
        the current class loader