edu.rice.cs.util
Class MD5ChecksumProperties

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<Object,Object>
          extended by java.util.Properties
              extended by edu.rice.cs.util.MD5ChecksumProperties
All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>

public class MD5ChecksumProperties
extends Properties

Create a property file with MD5 checksums

Version:
$Id: MD5ChecksumProperties.java 5236 2010-04-27 01:43:36Z mgricken $
See Also:
Serialized Form

Field Summary
static int BUFFER_SIZE
           
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
MD5ChecksumProperties()
           
MD5ChecksumProperties(Properties p)
           
 
Method Summary
 boolean addMD5(File f)
          Add the MD5 checksum for the data in the input stream to the properties, using the name of the file as key.
 boolean addMD5(File f, OutputStream os)
          Add the MD5 checksum for the data in the input stream to the properties, using the name of the file as key.
 boolean addMD5(String key, byte[] b)
          Add the MD5 checksum for the data in the byte array to the properties, using the specified key.
 boolean addMD5(String key, byte[] b, OutputStream os)
          Add the MD5 checksum for the data in the byte array to the properties, using the specified key.
 boolean addMD5(String key, File f)
          Add the MD5 checksum for the data in the file to the properties, using the specified key.
 boolean addMD5(String key, File f, OutputStream os)
          Add the MD5 checksum for the data in the file to the properties, using the specified key.
 boolean addMD5(String key, InputStream is)
          Add the MD5 checksum for the data in the input stream to the properties, using the specified key.
 boolean addMD5(String key, InputStream is, OutputStream os)
          Add the MD5 checksum for the data in the input stream to the properties, using the specified key.
static byte[] getMD5(byte[] b)
           
static byte[] getMD5(File f)
           
static byte[] getMD5(InputStream is)
          Return the MD5 checksum for the data in the stream
static byte[] getMD5(InputStream is, OutputStream os)
          Return the MD5 checksum for the data in the stream, while copying the data into the output stream.
static String getMD5String(byte[] b)
           
static String getMD5String(File f)
           
static String getMD5String(InputStream is)
          Return the MD5 checksum as string for the data in the stream.
static String getMD5String(InputStream is, OutputStream os)
          Return the MD5 checksum as string for the data in the stream, while copying the data into the output stream.
static void main(String[] args)
          Main method.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

MD5ChecksumProperties

public MD5ChecksumProperties()

MD5ChecksumProperties

public MD5ChecksumProperties(Properties p)
Method Detail

getMD5

public static byte[] getMD5(InputStream is,
                            OutputStream os)
                     throws IOException
Return the MD5 checksum for the data in the stream, while copying the data into the output stream. The output stream is not closed.

Parameters:
is - input stream
os - output stream (or null if no copying desired)
Returns:
MD5 checksum
Throws:
IOException

getMD5

public static byte[] getMD5(InputStream is)
                     throws IOException
Return the MD5 checksum for the data in the stream

Parameters:
is - input stream
Returns:
MD5 checksum
Throws:
IOException

getMD5String

public static String getMD5String(InputStream is,
                                  OutputStream os)
                           throws IOException
Return the MD5 checksum as string for the data in the stream, while copying the data into the output stream. The output stream is not closed.

Parameters:
is - input stream
os - output stream (or null if no copying desired)
Returns:
MD5 checksum string
Throws:
IOException

getMD5String

public static String getMD5String(InputStream is)
                           throws IOException
Return the MD5 checksum as string for the data in the stream.

Parameters:
is - input stream
Returns:
MD5 checksum string
Throws:
IOException

getMD5

public static byte[] getMD5(File f)
                     throws IOException
Throws:
IOException

getMD5String

public static String getMD5String(File f)
                           throws IOException
Throws:
IOException

getMD5

public static byte[] getMD5(byte[] b)
                     throws IOException
Throws:
IOException

getMD5String

public static String getMD5String(byte[] b)
                           throws IOException
Throws:
IOException

addMD5

public boolean addMD5(String key,
                      InputStream is,
                      OutputStream os)
               throws IOException
Add the MD5 checksum for the data in the input stream to the properties, using the specified key.

Parameters:
key - key to store the checksum under
is - input stream with the data
os - output stream to copy to (or null if not wanted)
Returns:
false if the new MD5 checksum didn't match an existing checksum
Throws:
IOException

addMD5

public boolean addMD5(String key,
                      InputStream is)
               throws IOException
Add the MD5 checksum for the data in the input stream to the properties, using the specified key.

Parameters:
key - key to store the checksum under
is - input stream with the data
Returns:
false if the new MD5 checksum didn't match an existing checksum
Throws:
IOException

addMD5

public boolean addMD5(String key,
                      File f,
                      OutputStream os)
               throws IOException
Add the MD5 checksum for the data in the file to the properties, using the specified key.

Parameters:
key - key to store the checksum under
f - file with the data
os - output stream to copy to (or null if not wanted)
Returns:
false if the new MD5 checksum didn't match an existing checksum
Throws:
IOException

addMD5

public boolean addMD5(String key,
                      File f)
               throws IOException
Add the MD5 checksum for the data in the file to the properties, using the specified key.

Parameters:
key - key to store the checksum under
f - file with the data
Returns:
false if the new MD5 checksum didn't match an existing checksum
Throws:
IOException

addMD5

public boolean addMD5(String key,
                      byte[] b,
                      OutputStream os)
               throws IOException
Add the MD5 checksum for the data in the byte array to the properties, using the specified key.

Parameters:
key - key to store the checksum under
b - byte array with the data
os - output stream to copy to (or null if not wanted)
Returns:
false if the new MD5 checksum didn't match an existing checksum
Throws:
IOException

addMD5

public boolean addMD5(String key,
                      byte[] b)
               throws IOException
Add the MD5 checksum for the data in the byte array to the properties, using the specified key.

Parameters:
key - key to store the checksum under
b - byte array with the data
Returns:
false if the new MD5 checksum didn't match an existing checksum
Throws:
IOException

addMD5

public boolean addMD5(File f,
                      OutputStream os)
               throws IOException
Add the MD5 checksum for the data in the input stream to the properties, using the name of the file as key.

Parameters:
f - file with the data
os - output stream to copy to (or null if not wanted)
Returns:
false if the new MD5 checksum didn't match an existing checksum
Throws:
IOException

addMD5

public boolean addMD5(File f)
               throws IOException
Add the MD5 checksum for the data in the input stream to the properties, using the name of the file as key.

Parameters:
f - file with the data
Returns:
false if the new MD5 checksum didn't match an existing checksum
Throws:
IOException

main

public static void main(String[] args)
                 throws IOException
Main method. Usage: no arguments --> input file list from standard in, output properties to standard out --> input file list from standard in, append output properties to file1 --> input file list from file1, append output properties to file 2

Throws:
IOException