Mercurial Hosting > luan
diff src/goodjava/io/IoUtils.java @ 1508:86c5e7000ecf
lucene.backup checksum
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 16 May 2020 17:56:02 -0600 |
parents | d80395468b4e |
children | 0ba144491a42 |
line wrap: on
line diff
--- a/src/goodjava/io/IoUtils.java Sat May 16 12:33:41 2020 +0300 +++ b/src/goodjava/io/IoUtils.java Sat May 16 17:56:02 2020 -0600 @@ -57,6 +57,16 @@ in.close(); } + public static long checksum(InputStream in) throws IOException { + long cs = 0; + int c; + while( (c=in.read()) != -1 ) { + cs = 31 * cs + c; + } + in.close(); + return cs; + } + static { // undo restrictions of modern scum @@ -71,4 +81,4 @@ return (SSLServerSocketFactory)SSLServerSocketFactory.getDefault(); } -} \ No newline at end of file +}