Package org.dspace.curate
Class Utils
- java.lang.Object
-
- org.dspace.curate.Utils
-
public class Utils extends Object
Utils contains a few commonly occurring methods.- Author:
- richardrodgers
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringchecksum(File file, String algorithm)Calculates and returns a checksum for the passed file using the passed algorithm.static Stringchecksum(InputStream in, String algorithm)Calculates and returns a checksum for the passed IO stream using the passed algorithm.static voidcopy(File inFile, File outFile)Performs a buffered copy from one file into another.static voidcopy(InputStream in, OutputStream out)Performs a buffered copy from one IO stream into another.static StringtoHex(byte[] data)
-
-
-
Method Detail
-
checksum
public static String checksum(File file, String algorithm) throws IOException
Calculates and returns a checksum for the passed file using the passed algorithm.- Parameters:
file- file on which to calculate checksumalgorithm- string for algorithm: 'MD5', 'SHA1', etc- Returns:
- checksum string of the calculated checksum
- Throws:
IOException- if IO error
-
checksum
public static String checksum(InputStream in, String algorithm) throws IOException
Calculates and returns a checksum for the passed IO stream using the passed algorithm.- Parameters:
in- input stream on which to calculate checksumalgorithm- string for algorithm: 'MD5', 'SHA1', etc- Returns:
- checksum string of the calculated checksum
- Throws:
IOException- if IO error
-
toHex
public static String toHex(byte[] data)
-
copy
public static void copy(File inFile, File outFile) throws IOException
Performs a buffered copy from one file into another.- Parameters:
inFile- input fileoutFile- output file- Throws:
IOException- if IO error
-
copy
public static void copy(InputStream in, OutputStream out) throws IOException
Performs a buffered copy from one IO stream into another. Note that stream closure is responsibility of caller.- Parameters:
in- input streamout- output stream- Throws:
IOException- if IO error
-
-