0

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!

Gianluca Ghettini
  • 11,129
  • 19
  • 93
  • 159
MCT
  • 21
  • 5

1 Answers1

0

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

Community
  • 1
  • 1
Gianluca Ghettini
  • 11,129
  • 19
  • 93
  • 159
  • thank you for your answwer, about the second question, my requirement is not writting it to a text file. It require to create a kind of .md5 file. The extension is .md5. How can create that kind of file? – MCT Aug 20 '15 at 10:51
  • well, the file extension can be anything, .txt, .md5 .pdf. it's the content of the file that matters. Check my edit on the answer – Gianluca Ghettini Aug 20 '15 at 11:24