Class FileUtilities
- java.lang.Object
-
- org.hortonmachine.gears.io.grasslegacy.utils.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 Summary
Constructors Constructor Description FileUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublearr2double(byte[] arr, int start)static floatarr2float(byte[] arr, int start)static intarr2int(byte[] arr, int start)static longarr2long(byte[] arr, int start)static byte[]BitSet2ByteArray(BitSet bs)static voidcopyFile(File in, File out)static voidcopyFile(String fromFile, String toFile)static booleandeleteFileOrDir(File filehandle)Returns true if all deletions were successful.static booleandeleteFileOrDirOnExit(File filehandle)Delete file or folder recursively on exit of the programstatic byte[]double2bytearray(double rastervalue)static BitSetfromByte(byte thebyte)static BitSetfromByteArray(byte[] bytes)static StringgetNameWithoutExtention(File file)static StringreadInputStreamToString(InputStream inputStream)Read from an inoutstream and convert the readed stuff to a String.static StringreplaceBackSlashes(String path)static byte[]toByteArray(BitSet bits)
-
-
-
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)
-
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
-
-