Class MetadataExtractor.FileUtil

  • Enclosing class:
    MetadataExtractor

    public static class MetadataExtractor.FileUtil
    extends java.lang.Object
    A series of utility methods for working with the file system. The methods herein are used in unit testing. Use them in production code at your own risk!
    Author:
    Drew Noakes https://drewnoakes.com
    • Constructor Summary

      Constructors 
      Constructor Description
      FileUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] readBytes​(java.io.File file)
      Reads the contents of a File into a byte[].
      static byte[] readBytes​(java.lang.String filePath)
      Reads the contents of a File into a byte[].
      static void saveBytes​(java.io.File file, byte[] bytes)
      Saves the contents of a byte[] to the specified File.
      • Methods inherited from class java.lang.Object

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

      • FileUtil

        public FileUtil()
    • Method Detail

      • saveBytes

        public static void saveBytes​(java.io.File file,
                                     byte[] bytes)
                              throws java.io.IOException
        Saves the contents of a byte[] to the specified File.
        Throws:
        java.io.IOException
      • readBytes

        public static byte[] readBytes​(java.io.File file)
                                throws java.io.IOException
        Reads the contents of a File into a byte[]. This relies upon File.length() returning the correct value, which may not be the case when using a network file system. However this method is intended for unit test support, in which case the files should be on the local volume.
        Throws:
        java.io.IOException
      • readBytes

        public static byte[] readBytes​(java.lang.String filePath)
                                throws java.io.IOException
        Reads the contents of a File into a byte[]. This relies upon File.length() returning the correct value, which may not be the case when using a network file system. However this method is intended for unit test support, in which case the files should be on the local volume.
        Throws:
        java.io.IOException