Use Fs.copytolocalfile (hdfspath,localpath), download HDFs file will be reported nullpointerexception, the specific error is:
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: in) at Hadoop.downFile.main (Downfile.java: A)
Solution: Change Fs.copytolocalfile (Hdfspath,localpath) to Fs.copytolocalfile (false,hdfspath,localpath,true);
Reason: Do not understand, but add these two after really can download
Download HDFs file NullPointerException in Java