Package org.dspace.curate
Class Utils
java.lang.Object
org.dspace.curate.Utils
Utils contains a few commonly occurring methods.
- Author:
- richardrodgers
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringCalculates 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 voidPerforms 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 Details
-
checksum
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
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
-
copy
Performs a buffered copy from one file into another.- Parameters:
inFile- input fileoutFile- output file- Throws:
IOException- if IO error
-
copy
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
-