在使用Hadoop上传本地文件到HDFS时出现 java.io.FileNotFoundException File /xxx/xxx.txt does not exist问题

Spring Cloud Feign MultipartFile文件上传踩坑之路(包含前端文件上传请求、后端文件保存到aliyun-oss文件服务器) 文件上传组件用的是ant-design的a-upload组件,我的界面如下所示:需要注意的只有FileUtils.js定义的uploadApi请求函数,其中为后端请求接口(“/imageConvert/upload”),文件上传方法必须定义为,在加入’Content-type’: ‘multipart/form-data’,后端即可用@RequestParam或者@RequestPart + MultipartFile 来接受文件。(无关紧要,用法大致相同,看你自己需求,这里只是提供一个参考范例) 阅读详情

问题描述

今天笔者在使用Hadoop时,调用copyFromLocalFile方法上传本地文件到HDFS时java.io.FileNotFoundException File /xxx/xxx.txt does not exist问题,代码如下:

    /**
     * 上传本地文件到HDFS
     * */
    @Test
    public void copyFromLocalFile() throws Exception {
        System.out.println("********上传本地文件到HDFS********");
        Path src = new Path("/home/hadoop/data/book.txt");
        Path dist = new Path("/hdfsapi/test/");
        fileSystem.copyFromLocalFile(src,dist);
    }

但是运行就出现下面的情况:

java.io.FileNotFoundException File /home/hadoop/data/book.txt does not exist

由于笔者是在CentOS机器上安装的Hadoop伪集群,因此这里配置本地文件路径为/home/hadoop/data/book.txt,而且确认CentOS机器上是存在上述文件的。

问题解决

后来我一想,这个是文件找不到,难道是权限问题,给hadoop用户这个文件777权限,发现依旧没问题。突然我想起来了,我这个代码是在Window系统上写的,且通过ssh连接到的CentOS机器,那么这里的本地应该是Window系统。于是我将其src路径修改为了Window系统上的文件路径:

    /**
     * 上传本地文件到HDFS
     * */
    @Test
    public void copyFromLocalFile() throws Exception {
        System.out.println("********上传本地文件到HDFS********");
        Path src = new Path("F:/Hadoop/hdfs/maven/envy-hdfs/src/main/resources/book.txt");
        Path dist = new Path("/hdfsapi/test/");
        fileSystem.copyFromLocalFile(src,dist);
    }

之后运行该方法,发现没有问题,然后查看Hadoop也已经出现了这个book.txt文件。

Java中FileNotFoundException异常的常见原因和解决方法 在Java编程中,FileNotFoundException是一个常见的异常,它表示在尝试访问文件时无法找到指定的文件。解决方法:确保程序具有足够的权限来读取指定的文件。解决方法:确保提供的文件路径是正确的,并且文件确实存在于指定的位置。在上面的示例代码中,如果提供的文件路径无效或文件不存在,Java将抛出FileNotFoundException异常,并显示相应的错误消息。文件被移动或删除:如果程序依赖的文件被移动或删除,尝试访问该文件时将抛出FileNotFoundException异常。 阅读详情

相关推荐

VisionMaster位置修正功能深度解析:如何让找圆工具自动跟随移动目标?

本文深度解析海康威视VisionMaster平台的位置修正功能,重点介绍如何通过模板匹配与找圆工具的智能联动实现移动目标的动态追踪。文章详细阐述了工业视觉检测中的坐标系同步原理、模板匹配配置技巧及异常处理策略,为工程师提供了一套完整的工业级解决方案。

uu89012的博客 286

使用Feign接口实现文件上传的解决方案

一般的情况下,后端有个微服务,暴露出一个文件上传的restful接口给前端,前端调用该接口获取上传后的链接以及oss key值完成上传。假设提供restful接口的这个服务叫做A,现在有个微服务B有个本地文件,需要将本地文件调用A文件文件上传接口上传到文件服务器,该如何做?一般情况下,一个文件上传的restful接口如下所示:......那对应的Feign接口就如下所示从直觉上来看,直接调用八成会出问题(笑),通过踩坑,我梳理了下后端调用Feign接口实现文件上传的改造点。

狂盗一枝梅的专栏 1658

立创·庐山派-K230-CanMV(嘉楠勘智)开发板通过ATK-ESP8266实现图像识别数据无线传输至原子云

本文详细介绍了如何使用立创·庐山派-K230-CanMV开发板,通过ATK-ESP8266 WIFI模块实现图像识别数据的无线传输至原子云平台。内容包括硬件连接、软件环境搭建、AT指令控制、原子云连接及数据上传的全过程,并提供了实用的调试技巧和常见问题解决方案,为物联网应用开发提供了完整实践指南。

potato的博客 743

(完美解决)java文件操作报错:java.io.FileNotFoundException(拒绝访问)

01-错误信息: Exception in thread "main" java.io.FileNotFoundException: e:b (拒绝访问。) at java.io.FileOutputStream.open0(Native Method) at java.io.FileOutputStream.open(Unknown Source) at java.io.FileOutputStream.<init>(Unknown Source) at java.io.FileOu

m0_61083409的博客 3万+

IB网络下不同租户业务隔离方案

IB(InfiniBand)网络隔离可以在不同的通信模式下实现,其中包括 IPoIB(IP over InfiniBand)通信模式。在 IPoIB 模式下,InfiniBand 网络可以承载 IP 数据包,使得基于 IP 的应用程序能够在 InfiniBand 网络上进行通信。在这种情况下,IB 网络隔离通常指通过配置 Partition Key(PKey)来实现不同的租户或应用程序之间的网络隔离。然而,IB 网络隔离并不仅限于 IPoIB 模式。

guganly的专栏 1529

calibre QRC提取寄生参数

typical将上面的文件QCI_flow里面的文件 在Cp 到当前 ,其实应该是某几个文件,但是我给忘记了 就全cp过来了 ,无影响,不过也希望大佬指正。

2202_75711937的博客 1523

通过 Feign 进行文件上传

转载来源:https://www.cnblogs.com/zjdxr-up/p/13466696.html 项目为spring cloud 项目,项目中对各部分能力业务进行了拆分,将公共的服务能力放在一个模块当中,通过 Feign 的方式 进行调用,feign 调用的本质还是http内部通信请求,实现模块之间的调用。 通过feign进行文件上传时,feign 侧示例代码如下: @FeignClient public interface UploadClient { @PostMapping(value

a_tzluy的博客 6075

国产信创服务器软硬件兼容情况1 --- ARM架构

信创,即信息技术应用创新产业,它是数据安全、网络安全的基础,也是新基建的重要组成部分...

一只猿的自我修养 4741

解决 调用copyFromLocalFile方法 java.io.FileNotFoundException File /xxx/xxx.txt does not exist.

因为我用的是windows机器连接linux 所以上传路径(src)要改成windows的路径 Path src=new Path("D:\\weixin\\b.txt"); Path dst=new Path("/hdfsapi/test/"); fileSystem.copyFromLocalFile(src,st); ...

qq_21277357的博客 3120

sqoop抽取mysql的数据到hive表里面,字段内容被自动截取,导致字段不全的问题解决

今天央视重新转播NBA,写篇博客纪念一下这个重要的日子,湖人的表现就呵呵了!!!! 强行转到博客的主题来 mysql的字段属性:该字段能存下的值比如:“山东” `province` varchar(3) NOT NULL COMMENT '省份' 用sqoop sqoop import --connect "jdbc:mysql://xxxxxx:3306/xxxxxx?tinyInt1isBit=false&zeroDateTimeBehavior=convertToNull..

放肆桀骜 964

国科大学习资料--遥感原理集图像处理(尤红建)--2019年期末考试

国科大学习资料–遥感原理集图像处理(尤红建)–2019年期末考试 国科大学习资料–遥感原理集图像处理(尤红建)–2019年期末考试 国科大学习资料–遥感原理集图像处理(尤红建)–2019年期末考试 ================================================================== ================================================================== ==============

无名何许人的博客 1470

spring cloud feign 多文件上传实现

单文件上传网上有很多教程 多文件以及多文件附带其他参数 的教程 几乎没有 经过研究和参考其他文章 详细的原理不再讲解 实现过程如下: 加入feign 支持上传的组件: <dependency> <groupId>io.github.openfeign.form</groupId> &...

weixin_40740875的博客 649

120、NPU的Mythic M1076:模拟存算一体NPU

这篇文章分享了作者调试Mythic M1076模拟存算一体NPU的实战经验,主要包含以下要点: 硬件设计陷阱:参考电压输入必须使用低ESR电容,普通贴片电容会导致模拟计算阵列工作异常。 核心技术原理: 采用真正的存算一体架构,将权重存储为模拟电压 使用浮栅晶体管存储权重,通过电流叠加实现乘法运算 包含108个计算单元阵列(Tile),每个256×256规模 使用注意事项: 编程模型特殊,需要依赖SDK自动映射网络层 存在6-8位有效精度限制,需用量化感知训练 功耗特性独特,静态偏置电流占主要功耗 调试手段有

m0_50546716的博客 122

feign传输文件

feign、多文件、上传文件

u011649691的博客 5183

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Feign传递文件以及MultipartFile对象

Feign微服务调用传递文件以及MultipartFile参数对象,多个参数,MultipartFile对象和json数据。

yangfeng20的博客 1万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Feign 实现文件上传

早期Fegin 本身是没有上传文件的功能,要想实现文件上传,需要编写Encoder去实现文件上传。现在Feign官方提供了字项目 feign-form。

xu990128638的专栏 1299

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

java.io.FileNotFoundException: xxx.txt (系统找不到指定的文件。) 的错误解决办法

解决file读取文件路径并分析

U7_7cc的博客 1万+

在Spring Cloud中使用OpenFeign完成从一个微服务上传到另一个微服务中

跨服务上传文件,嘿嘿,来一篇实用性高的,本篇将主要完成在Feign中上传文件到另一个微服务中。步骤如下: 我们需要在服务提供者和服务消费者的项目中添加相应的依赖: 对于服务提供者的项目,你需要添加Spring Boot的Web依赖和Spring Cloud的Feign依赖。在pom.xml文件中添加以下依赖:

好看的皮囊千篇一律,有趣的灵魂万里挑一。 3613

Feign实现多文件上传,Open Feign多文件上传解决方案

如何使用Feign实现多文件上传,Open Feign多文件上传解决方案 废话不多说,直接上代码 用feign多文件上传的Controller代码如下 @Slf4j @RestController @RequestMapping("/store") @Api(description = "店铺管理接口", tags = "店铺管理接口") public class StoreController { @Autowired private StoreService storeService

m0_43413873的博客 3070

hadoop :java.io.FileNotFoundException: File does not exist:

点击打开链接转自:http://blog.163.com/silver9886@126/blog/static/35971862201441134010403/ 1.用hadoop的eclipse插件下M/R程序的时候,有时候会报 Exception in thread "main" java.lang.IllegalArgumentException: Pathname

epitomizelu的专栏 2万+

Hadoop的java程序报错Exception in thread "main" java.io.FileNotFoundException: File does not exis

找了半天发现是因为路径没有写全 正确路径应该是E:/abc.txt 注意检查路径是不是写全了,尤其是后缀!!!

Abigal 4453

feign接口传输InputStream

【代码】feign接口传输InputStream。

qq_40250122的博客 2902

ecplise连接hadoop成功却不能进行文件操作的问题

1.Permission denied: user=wuhon, access=WRITE, inode="/":fafa:supergroup:drwxr-xr-x 2.in thread "main" org.apache.hadoop.fs.UnsupportedFileSystemException: No FileSystem for scheme "hdfs"

FA的博客 623

feign技巧 - form方式传值(上传文件)

feign技巧 - form方式传值

夫礼者的专栏 3307

Feign实现文件上传

private MultipartFile string2MultipartFile(MultipartFile multipartFile) { String fileName = multipartFile.getName(); FileItemFactory factory = new DiskFileItemFactory(); DiskFileItem item = (DiskFileItem) factory.createItem("image..

llp1990311的博客 4233

【Feign实现文件上传】

【Feign实现文件上传】

lzy99534的博客 2029
上一篇: SpringBoot整合SpringSecurity出现Illegal overloaded getter method with ambiguous type for property enable
下一篇: IDEA抛出key com.tang.intellij.lua.luacheck.LuaCheckSettings问题解决
啃饼思录
博客等级 码龄9年 11粉丝 18原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值