You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Emmanuel Bourg <eb...@apache.org> on 2006/03/29 11:46:47 UTC

[io] File checksum

Hi,

I have found myself recoding a file checksum function for several 
projects, I wonder if such a function could be added to [io]. Something 
like this:

     public static Checksum checksum(File file, Checksum cs)

the usage would look like this:

     long crc = FileUtils.checksum(file, new CRC32()).getValue();

What do you think ?

Emmanuel Bourg

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [io] File checksum

Posted by Emmanuel Bourg <eb...@apache.org>.
Emmanuel Bourg wrote:
> or as a ChecksumInputStream computing automatically the checksum of the 
> data read. Or both.

Forget this idea, it already exists in the JDK as 
java.util.zip.CheckedInputStream.

Emmanuel Bourg


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [io] File checksum

Posted by Emmanuel Bourg <eb...@apache.org>.
Stephen Colebourne wrote:
> +1 to the idea.
> 
> I would suggest that we need one variation in [codec]
> and one in [io] as checksums are not just file based.

I don't know how it could be integrated to [codec], maybe in DigestUtils ?

It may be interesting to compute the checksums on streams too, maybe as 
a similar method in IOUtils

     public static Checksum checksum(InputStream in, Checksum checksum);

or as a ChecksumInputStream computing automatically the checksum of the 
data read. Or both.

Emmanuel Bourg


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [io] File checksum

Posted by Stephen Colebourne <sc...@btopenworld.com>.
+1 to the idea.

I would suggest that we need one variation in [codec]
and one in [io] as checksums are not just file based.

Stephen


--- Emmanuel Bourg <eb...@apache.org> wrote:
> Hi,
> 
> I have found myself recoding a file checksum
> function for several 
> projects, I wonder if such a function could be added
> to [io]. Something 
> like this:
> 
>      public static Checksum checksum(File file,
> Checksum cs)
> 
> the usage would look like this:
> 
>      long crc = FileUtils.checksum(file, new
> CRC32()).getValue();
> 
> What do you think ?
> 
> Emmanuel Bourg
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-dev-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org