1 18 19 package org.apache.tools.ant.types.selectors.modifiedselector; 20 21 22 import java.io.File ; 23 24 25 33 public class HashvalueAlgorithm implements Algorithm { 34 35 40 public boolean isValid() { 41 return true; 42 } 43 44 51 public String getValue(File file) { 54 try { 55 if (!file.canRead()) { 56 return null; 57 } 58 java.io.FileInputStream fis = new java.io.FileInputStream (file); 59 byte[] content = new byte[fis.available()]; 60 fis.read(content); 61 fis.close(); 62 String s = new String (content); 63 int hash = s.hashCode(); 64 return Integer.toString(hash); 65 } catch (Exception e) { 66 return null; 67 } 68 } 69 70 71 75 public String toString() { 76 return "HashvalueAlgorithm"; 77 } 78 79 } 80 | Popular Tags |