sitelink1 | http://blog.naver.com/lseykwang?Redirect...0045269556 |
---|---|
sitelink2 | https://blog.naver.com/madosa3000/220833610196 |
sitelink3 | |
sitelink4 | |
sitelink5 | |
sitelink6 |
·미리보기 | 소스복사·
- public long getFileCRC32(String fileName) throws IOException {
- long crc32Int = -1;
- CRC32 crc32 = new CRC32();
- CheckedInputStream in = null;
- try {
- in = new CheckedInputStream(new FileInputStream(fileName), crc32);
- while (in.read() != -1);
- crc32Int = crc32.getValue();
- } catch (FileNotFoundException e) {
- System.err.println("CheckedIODemo: " + e);
- System.exit(-1);
- } catch (IOException e) {
- System.err.println("CheckedIODemo: " + e);
- System.exit(-1);
- } finally {
- if(in != null) {
- in.close();
- }
- }
- return crc32Int;
- }
사용법 => long crc32Value = getFileCRC32("c:test.txt");