On Wed, 21 Nov 2018 04:21:10 -0600, Jantje. <[email protected]> wrote:
>Attached is a little Java program I did years ago for exactly that purpose. It
>uses the excellent jzos for reading just about any type of dataset or file.
>
So far for attachments...
Here is the code:
package com.tme.mainframemove;
import com.ibm.jzos.FileFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5CheckSum {
public static byteíù createChecksum(String filename) throws IOException,
NoSuchAlgorithmException {
InputStream inputStream = FileFactory.newInputStream(filename);
//InputStream inputStream = new FileInputStream(filename);
byteíù buffer = new byteí1024ù;
MessageDigest complete = MessageDigest.getInstance("MD5");
int numRead;
do {
numRead = inputStream.read(buffer);
if (numRead > 0) {
complete.update(buffer, 0, numRead);
}
} while (numRead != -1);
inputStream.close();
return complete.digest();
}
public static String getMD5Checksum(String filename) throws IOException,
NoSuchAlgorithmException {
byteíù b = createChecksum(filename);
String result = "";
for (int i = 0; i < b.length; i++) {
result +=
Integer.toString((bíiù & 0xff) + 0x100, 16).substring(1);
}
return result;
}
public static void getMD5CheckSums(String parmFileName) throws IOException,
NoSuchAlgorithmException {
BufferedReader fileNames = FileFactory.newBufferedReader(parmFileName);
try {
String datasetName;
while ((datasetName = fileNames.readLine()) != null) {
System.out.print(String.format("%1#-50s", datasetName));
System.out.println(getMD5Checksum(datasetName));
}
} finally {
fileNames.close();
}
}
public static void main(String argsíù) {
try {
getMD5CheckSums(argsí0ù);
} catch (Exception e) {
e.printStackTrace();
}
}
}
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN