1 19 20 package org.netbeans.modules.project.ant.task; 21 22 import java.io.File ; 23 import java.io.FileInputStream ; 24 import java.io.InputStream ; 25 import java.io.IOException ; 26 import org.apache.tools.ant.BuildException; 27 import org.apache.tools.ant.Task; 28 import org.netbeans.spi.project.support.ant.CRC32Calculator; 29 30 35 public final class ShowCRCTask extends Task { 36 37 private File f; 38 public void setFile(File f) { 39 this.f = f; 40 } 41 42 43 public ShowCRCTask() {} 44 45 public void execute() throws BuildException { 46 if (f == null) { 47 throw new BuildException("No 'file' attr"); 48 } 49 try { 50 InputStream is = new FileInputStream (f); 51 try { 52 String crc = CRC32Calculator.computeCrc32(is); 53 log("CRC32 for " + f + ": " + crc); 54 } finally { 55 is.close(); 56 } 57 } catch (IOException e) { 58 throw new BuildException(e, getLocation()); 59 } 60 } 61 62 } 63 | Popular Tags |