how to create a file which contains an MD5 hash of another file in java?

364 Views Asked by At

I have an test.txt file. Then, i try to get the md5 string of that file by MessageDigest. But, my question is not that. My requirement is to create an test.txt.md5 file which contains the md5 string.

How can i do that in java?

Thank you every much!

1

There are 1 best solutions below

2
On

You can decompose your question in two smaller questions:

  1. How to compute the MD5 hash of a file in Java
  2. How to save a text file in Java

First: Getting a File's MD5 Checksum in Java

Second:

try (PrintStream out = new PrintStream(new FileOutputStream("filename.md5"))) {
    out.print(text);
}

if you decompose your question you are more likely to find already made questions/answers straight on SO