Class FileUtilities


  • public class FileUtilities
    extends Object

    Various file utilities usefull when dealing with bytes, bits and numbers

    Since:
    1.1.0
    Author:
    Andrea Antonello - www.hydrologis.com
    • Constructor Detail

      • FileUtilities

        public FileUtilities()
    • Method Detail

      • double2bytearray

        public static byte[] double2bytearray​(double rastervalue)
      • fromByteArray

        public static BitSet fromByteArray​(byte[] bytes)
      • fromByte

        public static BitSet fromByte​(byte thebyte)
      • BitSet2ByteArray

        public static byte[] BitSet2ByteArray​(BitSet bs)
      • toByteArray

        public static byte[] toByteArray​(BitSet bits)
      • copyFile

        public static void copyFile​(String fromFile,
                                    String toFile)
      • copyFile

        public static void copyFile​(File in,
                                    File out)
      • arr2float

        public static float arr2float​(byte[] arr,
                                      int start)
      • arr2int

        public static int arr2int​(byte[] arr,
                                  int start)
      • arr2long

        public static long arr2long​(byte[] arr,
                                    int start)
      • arr2double

        public static double arr2double​(byte[] arr,
                                        int start)
      • deleteFileOrDir

        public static boolean deleteFileOrDir​(File filehandle)
        Returns true if all deletions were successful. If a deletion fails, the method stops attempting to delete and returns false.
        Parameters:
        filehandle -
        Returns:
        true if all deletions were successful
      • deleteFileOrDirOnExit

        public static boolean deleteFileOrDirOnExit​(File filehandle)
        Delete file or folder recursively on exit of the program
        Parameters:
        filehandle -
        Returns:
        true if all went well
      • readInputStreamToString

        public static String readInputStreamToString​(InputStream inputStream)
        Read from an inoutstream and convert the readed stuff to a String. Usefull for text files that are available as streams.
        Parameters:
        inputStream -
        Returns:
        the read string
      • replaceBackSlashes

        public static String replaceBackSlashes​(String path)
      • getNameWithoutExtention

        public static String getNameWithoutExtention​(File file)