public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.rootdir","hdfs://master:9000/hbase");
conf.set("hbase.zookeeper.quorum","master:2181");
HTable hTable1 = new HTable(conf, "evidence");
String name ="IMG_2067.JPG";
Scan scan1 = new Scan();
while (name.length() <= 19){
name= "0" + name;
}
scan1.setStartRow((name+":000:0").getBytes());
scan1.setStopRow((name+":999:9").getBytes());
ResultScanner scanner1 = hTable1.getScanner(scan1);
for (Result result1 : scanner1) {
String sha1 = new String(result1.getValue("info".getBytes(), "sha".getBytes()));
String md5 = new String(result1.getValue("info".getBytes(), "md5".getBytes()));
String salt = new String(result1.getValue("info".getBytes(), "salt".getBytes()));
System.out.println("SHA1值是:"+sha1+"\t"+"SALT值是:"+salt+"\t"+"MD5值是:"+md5);
}
}
运行之后,三个值都输出了,但最后仍会抛空指针异常
Exception in thread "main" SHA1值是:E4405661AF00F88E8A446CB1FD25061710EC3937 SALT值是:3504294131628967 MD5值是:63ec5a207b4672c79f74ad1d83a61b26882da8ec9ca69e7e
java.lang.NullPointerException
at java.lang.String.(String.java:556)
at hadoop.test.main(test.java:29)