How to check file integrity

Is there any way in java to check file integrity in java.

Such as by implementing checksum machanism.

if its not possible in java could you please suggest me some other solution.

[197 byte] By [Rakesh83a] at [2007-11-27 11:42:45]
# 1

Why do you think you need to "check file integrity"? What does "checking file integrity" mean to you?

The file system, disk controller, etc. are responsible for making sure that the bytes that you try to write get written correctly. Assume that they work. If you have reason to believe otherwise, you need a diagnostic tool, maybe a new disk, not a Java program.

If "file integrity" to you means that your file has a certain format, then sure, you can implement a checksum or some other means to verify that the contents conform to that.

jverda at 2007-7-29 17:45:59 > top of Java-index,Java Essentials,Java Programming...
# 2

java.util.zip: CheckSum and Check[Input/Output]Stream.

BigDaddyLoveHandlesa at 2007-7-29 17:45:59 > top of Java-index,Java Essentials,Java Programming...
# 3

Do you mean using a security hash key or something so that you will know if the file has been tampered with?

I believe md5 is a widely used hash function. Googling md5 and java yields quite a few results like the one below.

http://www.twmacinta.com/myjava/fast_md5.php

Illua at 2007-7-29 17:45:59 > top of Java-index,Java Essentials,Java Programming...
# 4

Create a checksum

Examples at http://www.rgagnon.com/javadetails/java-0416.html

--

http://www.rgagnon.com/howto.html

RealHowToa at 2007-7-29 17:45:59 > top of Java-index,Java Essentials,Java Programming...
# 5

> Create a checksum

>

> Examples at

> http://www.rgagnon.com/javadetails/java-0416.html

Mr. Gagnon, is that you? I've used you as a reference numerous times. Thanks for sharing your work.

~

yawmarka at 2007-7-29 17:45:59 > top of Java-index,Java Essentials,Java Programming...
# 6

> Mr. Gagnon, is that you?

Yep

> I've used you as a reference

> numerous times. Thanks for sharing your work.

My pleasure.

Bye.

RealHowToa at 2007-7-29 17:45:59 > top of Java-index,Java Essentials,Java Programming...
# 7

> Yep

> My pleasure.

> Bye.

brevity is the soul of wit. : )

i like your database how tos. they are very helpful.

TuringPesta at 2007-7-29 17:45:59 > top of Java-index,Java Essentials,Java Programming...
# 8

Actully i am receiving these file from a remote machine... and on this i want to check file Integrity .

Rakesh83a at 2007-7-29 17:45:59 > top of Java-index,Java Essentials,Java Programming...
# 9

> Actully i am receiving these file from a remote

> machine... and on this i want to check file Integrity

.

Then you need to copy its checksum file as well.

BigDaddyLoveHandlesa at 2007-7-29 17:45:59 > top of Java-index,Java Essentials,Java Programming...