码迷,mamicode.com
首页 > 编程语言 > 详细

用java下载hdfs文件报NullPointerException

时间:2016-01-19 12:15:44      阅读:264      评论:0      收藏:0      [点我收藏+]

标签:

用fs.copyToLocalFile( hdfsPath,localPath);下载hdfs的文件会报NullPointerException,具体报错为:

java.lang.NullPointerException
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1012)
    at org.apache.hadoop.util.Shell.runCommand(Shell.java:487)
    at org.apache.hadoop.util.Shell.run(Shell.java:460)
    at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:720)
    at org.apache.hadoop.util.Shell.execCommand(Shell.java:813)
    at org.apache.hadoop.util.Shell.execCommand(Shell.java:796)
    at org.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:656)
    at org.apache.hadoop.fs.FilterFileSystem.setPermission(FilterFileSystem.java:490)
    at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:462)
    at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:428)
    at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:908)
    at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:889)
    at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:786)
    at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:365)
    at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:338)
    at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:289)
    at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1970)
    at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1939)
    at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1915)
    at hadoop.downFile.downloadFileorDirectoryOnHDFS(downFile.java:29)
    at hadoop.downFile.main(downFile.java:12)

解决方法:将fs.copyToLocalFile( hdfsPath,localPath);改为fs.copyToLocalFile( false,hdfsPath,localPath,true);

原因:不理解,但加上这两个后确实可以下载

用java下载hdfs文件报NullPointerException

标签:

原文地址:http://www.cnblogs.com/zhuzhixijiang/p/5141454.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!