celine_chen
2017-04-03 15:10
采纳率: 33.3%
浏览 1.9k
已采纳

为什么属性能获取值,但仍抛出空指针异常

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)

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • celine_chen 2017-04-03 15:25
    已采纳

    没事了。。。自己解决了。。。。因为有两段值,一个有那三个值,一个没有

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题