title: HDFS File Checksum
body: <p>I am trying to check the consistency of a file after copying to HDFS using Hadoop API - DFSCleint.getFileChecksum(). </p>
  
  <p>I am getting the following output for the above code:</p>
  
  <pre><code>Null
  HDFS : null
  Local : null
  </code></pre>
  
  <p>Can anyone point out the error or mistake?
  Here is the Code : </p>
  
  <pre><code>import java.io.IOException;
  
  import org.apache.hadoop.conf.Configuration;
  import org.apache.hadoop.fs.FileChecksum;
  import org.apache.hadoop.fs.FileSystem;
  import org.apache.hadoop.fs.LocalFileSystem;
  import org.apache.hadoop.fs.Path;
  
  
  public class fileCheckSum {
  
      /**
       * @param args
       * @throws IOException 
       */
      public static void main(String[] args) throws IOException {
          // TODO Auto-generated method stub
  
          Configuration conf = new Configuration();
  
           FileSystem hadoopFS = FileSystem.get(conf);
      //  Path hdfsPath = new Path("/derby.log");
  
          LocalFileSystem localFS = LocalFileSystem.getLocal(conf);
      //      Path localPath = new Path("file:///home/ubuntu/derby.log");
  
  
      //  System.out.println("HDFS PATH : "+hdfsPath.getName());
      //      System.out.println("Local PATH : "+localPath.getName());
  
          FileChecksum hdfsChecksum = hadoopFS.getFileChecksum(new Path("/derby.log"));
          FileChecksum localChecksum = localFS.getFileChecksum(new Path("file:///home/ubuntu/derby.log"));
  
  
          if(null!=hdfsChecksum || null!=localChecksum){
              System.out.println("HDFS Checksum : "+hdfsChecksum.toString()+"\t"+hdfsChecksum.getLength());
              System.out.println("Local Checksum : "+localChecksum.toString()+"\t"+localChecksum.getLength());
  
              if(hdfsChecksum.toString().equals(localChecksum.toString())){
                  System.out.println("Equal");
              }else{
                  System.out.println("UnEqual");
  
              }
          }else{
              System.out.println("Null");
              System.out.println("HDFS : "+hdfsChecksum);
              System.out.println("Local : "+localChecksum);
  
          }
  
      }
  
  }
  </code></pre>