hadoop中用copyToLocalFile方法下载报NullPointerException该怎么办
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,这篇文章将为大家详细讲解有关hadoop中用copyToLocalFile方法下载报NullPointerException该怎么办,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文
千家信息网最后更新 2025年12月02日hadoop中用copyToLocalFile方法下载报NullPointerException该怎么办
这篇文章将为大家详细讲解有关hadoop中用copyToLocalFile方法下载报NullPointerException该怎么办,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
/** * 下载文件 */ @Test public void download() throws Exception { fs.copyToLocalFile(new Path("hdfs://master:9000/aa/lidunhui.jpg"), new Path("e://wangbadan.txt")); }运行该下载测试报空指针异常,如下:
java.lang.NullPointerException at java.lang.ProcessBuilder.start(ProcessBuilder.java:1010) at org.apache.hadoop.util.Shell.runCommand(Shell.java:445) at org.apache.hadoop.util.Shell.run(Shell.java:418) at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:650) at org.apache.hadoop.util.Shell.execCommand(Shell.java:739) at org.apache.hadoop.util.Shell.execCommand(Shell.java:722) at org.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:633) at org.apache.hadoop.fs.FilterFileSystem.setPermission(FilterFileSystem.java:467) at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:456) at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:424) at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:906) at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:887) at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:784) 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:1968) at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1937) at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1913) at com.jasun.hadoop.hdfs.HdfsUtil.download(HdfsUtil.java:62) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
解决办法,如下:
将fs.copyToLocalFile( hdfsPath,localPath);改为fs.copyToLocalFile( false,hdfsPath,localPath,true)
/** * 下载文件 */ @Test public void download() throws Exception { fs.copyToLocalFile(false, new Path("hdfs://master:9000/aa/lidunhui.jpg"), new Path("e://wangbadan.txt"), true); }关于hadoop中用copyToLocalFile方法下载报NullPointerException该怎么办就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
中用
怎么办
方法
内容
文件
文章
更多
知识
篇文章
不错
办法
指针
质量
参考
帮助
有关
测试
运行
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
军营网络安全黑板报武警
下面属于网络安全服务
常见的软件开发方法比较
协同网络安全
广州企业软件开发要多少钱
TcL软件开发在几个城市
苹果电脑学软件开发可以吗
办理安装网络安全管理系统
格尔木软件开发
美国的科技网络技术
山东戴尔服务器授权代理云服务器
商场网络安全管理员
公安机关dna数据库的作用
bs服务器教程
网络安全术语100句
bms软件开发怎么样 知乎
数据库视图题库
长连接服务器
惠普哪个系列适合软件开发
中国人民公安大学网络安全
数据库日常操作任务
安卓系统是哪个软件开发的
国家网络安全实施什么制度
深圳市影榜网络技术
吉祥棋牌服务器地
软件开发ide
怎么优化服务器延迟
富国基金互联网科技
软件开发中参数设置用哪种方式
中职校网络技术教材哪个好