org.dspace.curate
Class Utils

java.lang.Object
  extended by org.dspace.curate.Utils

public class Utils
extends Object

Utils contains a few commonly occurring methods.

Author:
richardrodgers

Constructor Summary
Utils()
           
 
Method Summary
static String checksum(File file, String algorithm)
          Calculates and returns a checksum for the passed file using the passed algorithm.
static String checksum(InputStream in, String algorithm)
          Calculates and returns a checksum for the passed IO stream using the passed algorithm.
static void copy(File inFile, File outFile)
          Performs a buffered copy from one file into another.
static void copy(InputStream in, OutputStream out)
          Performs a buffered copy from one IO stream into another.
static String toHex(byte[] data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
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 checksum
algorithm - string for algorithm: 'MD5', 'SHA1', etc
Returns:
checksum string of the calculated checksum
Throws:
IOException

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 checksum
algorithm - string for algorithm: 'MD5', 'SHA1', etc
Returns:
checksum string of the calculated checksum
Throws:
IOException

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 -
outFile -
Throws:
IOException

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 stream
out - output stream
Throws:
IOException


Copyright © 2012 DuraSpace. All Rights Reserved.