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

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

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
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波