java通过SmbFile操作远程共享盘内文件(非网络挂在盘,类似\\192.168.1.1这种共享盘)

不止是打印机:利用OpenWRT/潘多拉端口转发,让主路由轻松访问次级路由所有设备(SMB/FTP等) 本文详细介绍了如何利用OpenWRT/潘多拉端口转发技术,实现主路由对次级路由所有设备的无缝访问,包括SMB文件共享、FTP传输和打印机调用。通过修改子路由IP网段、配置防火墙规则和多服务映射实战案例,解决多路由环境下的IP冲突和服务隔离问题,提升网络管理效率。 阅读详情

首先导入jcifs-1.3.15.jar包或导入以下依赖

<dependency>
    <groupId>jcifs</groupId>
    <artifactId>jcifs</artifactId>
    <version>1.3.15</version>
</dependency>

话不多说,然后就是敲demo了

/**

*列出共享文件夹中所有文件

*/

  public String[] listFile(String url) {

        SmbFile remoteFile = new SmbFile(url);
          if(remoteFile.exists()) {
                        String[] files = remoteFile.list();
                        remoteFile.connect();
                        String[] files = remoteFile.list();

                       return  files;
                }

               return null;

   }

     /**
     * 复制图片
     * @param oldpath文件共享路径
     * @param newpath本地路径
     * @param filename文件名
     */
    public void copyFile(String oldpath,String newpath,String filename) {
        SmbFile remoteFile = null;
        InputStream in = null;
        OutputStream out = null;
        try {
            remoteFile = new SmbFile(oldpath+filename);
            remoteFile.connect();
            System.out.println(filename+"复制的文件是否存在:"+remoteFile.exists());
            if(remoteFile==null) {
                return ;
            }    
            in = new BufferedInputStream(new SmbFileInputStream(remoteFile));
            out = new BufferedOutputStream(new FileOutputStream(newpath+File.separator+filename));
            byte[] buffer = new byte[1024];  
            while (in.read(buffer) != -1)  
            {  
                out.write(buffer);  
                buffer = new byte[1024];  
            }  
        } catch (MalformedURLException e1) {
            e1.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally{
            if(out!=null) {
                try {
                    out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }                
            }
            if(in!=null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                
            }
        }
        
    }                 

▄█▀█●老铁,站住!别跑,我又不收你钱,如果我的demo能够帮助到你,请给我一个赞吧!

错误集:smbclient访问Windows共享文件夹报错误:protocol negotiation failed: NT_STATUS_CONNECTION_RESET smbclient访问Windows共享文件夹报错误:protocol negotiation failed: NT_STATUS_CONNECTION_RESET 文章目录smbclient访问Windows共享文件夹报错误:protocol negotiation failed: NT_STATUS_CONNECTION_RESET报错现象:解决办法: 报错现象: [root@bogon ~]#smbclient -L//192.168.2.1/ protocol negotiation failed: 阅读详情

相关推荐

基于Smb协议实现网络文件传输

SMB 是 Server Message Block 的缩写。它是一种网络文件共享协议,允许用户与远程计算机和服务器通信,使他们能够在网络上访问文件、目录、打印机和端口等资源。SMB 在 TCP/IP 协议栈的应用层(第 7 层)上操作,并使用 TCP/IP 的 445 端口。目前我们常见的共享文件方式基本都是支持SMB协议。文件共享:SMB 的主要用途之一是文件共享。SMB 允许多个用户访问和共享存储在远程服务器上的文件,就像它们在自己的本地设备上一样。这使得在网络中的协作和共享资源变得简单。

Eshare分享 6239

Mac访问Windows共享文件教程

今天刚好有个访问Windows共享文件需求 前提 Windows系统下已开启共享功能,网络是连通的 打开顶部菜单 “前往”,选择最下面的 “连接服务器...” 输入要共享的地址,格式为"smb://192.168.1.1" 选择要装载的磁盘 输入正确的账号密码访问即可 ...

Java&AI小吕布的博客 2672

jcifs-1.3.15.jar

这是smb读取局域网另外一台机器的包,用eclipse导入了不报错,后续没问题了再加

springboot 集成 smbFile 操作Windos共享文件夹

前言:最近某项目新增一个需求,需要将原本上传到tomcat 应用服务器上的文件上传到 windos 的共享文件夹,所以综合了网上资料,自己开始了如下尝试。 一、引入相关依赖 1、使用smbFile 操作共享文件夹需要用到以下jar 包 <!-- https://mvnrepository.com/artifact/org.samba.jcifs/jcifs java连接共享文件夹--&g...

wxw1997a的博客 5144

利用jcifs-1.3.15.jar实现共享文件上传下载

利用jcifs-1.3.15.jar实现局域网内共享文件的下载上传demo,主要为新手提供样例,资深专家请略过,传输大文件比如百兆可能中间出现问题。

超声波清洗机拆解实录:从电路板到换能器,一文看懂内部构造(附高清图)

本文详细拆解了超声波清洗机的内部构造,从电路板设计到换能器工作原理,揭示了其核心技术。通过高清图片和详细分析,展示了功率放大电路、高频变压器及压电换能器等关键部件,为电子爱好者和维修技术人员提供了实用的故障诊断和元件二次利用指南。

grape的博客 1209

Android 访问windows共享文件夹

Android 访问windows共享文件夹

u014017003的博客 4165

从mseed到SAC格式转换全攻略:mseed2sac工具安装与批量处理技巧

本文详细介绍了如何将mseed格式的地震数据高效转换为SAC格式,涵盖mseed2sac工具的安装、单文件转换技巧、批量处理自动化实现以及元数据高级处理策略。通过具体命令和脚本示例,帮助地震学研究者快速掌握数据预处理的关键技术,提升波形数据分析效率。

ruby5的博客 933

Ubuntu 访问共享目录

sudo apt-get install samba 安装samba 之后。 在打开文件夹的目录下按ctrl+L。直接在地址栏输入: smb://192.168.1.1 之后按照提示输入域密码就可以访问共享文件夹。

weixin_41032420的博客 592

UDS 诊断 - CommunicationControl(通信控制)(0x28)服务 诊断

字节参数名称字节值#1CommunicationControl(通信控制)请求SID0x28#2#3communicationType(通信类型)#4nodeIdentificationNumer(节点标识符)(高位字节)controlType 为 0x04 或 0x05 时,使用该参数#5nodeIdentificationNumer(节点标识符)(低位字节)controlType 为 0x04 或 0x05 时,使用该参数。

耳朵东金子千的博客 1829

CentOS 7下Oracle 11G RAC静默安装避坑指南:从网络规划到共享存储配置全流程

本文详细介绍了在CentOS 7环境下进行Oracle 11G RAC静默安装的全流程,包括网络规划、共享存储配置和系统参数调优等关键步骤。特别针对静默安装过程中的常见问题提供了实用的避坑指南和优化建议,帮助技术人员高效完成企业级数据库部署。

weixin_29234509的博客 133

linux windows smb共享,Linux下搭建SMB文件共享服务,Linux/Windows互联互通

一丶简介:SMB协议是建立在NetBIOS协议之上的应用协议,是基于TCP138、139两个端口的服务,NetBIOS出现之后,Microsoft就使用NetBIOS实现了一个网络文件/打印服务系统。这个系统基于NetBIOS设定了一套文件共享协议,Microsoft称之为SMB(Server Message Block) 协议,这个协议被用于Lan Manager和Windows服务器系统中,实...

weixin_32258183的博客 780

2025年华为杯D题:低空湍流监测及最优航路规划思路与Matlab实现

2025年华为杯D题:低空湍流监测及最优航路规划思路与Matlab实现

前程算法屋的博客 777

java 使用smb获取共享文件夹文件 和上传到共享文件夹(smb协议 局域网共享文件夹文件操作)

首先导入依赖 <dependency> <groupId>jcifs</groupId> <artifactId>jcifs</artifactId> <version>1.3.17</version> </dependency> 工具类(上代码) import java.io.BufferedOutputStream; import java.io.Fil

这个柠檬有丶酸的博客 2875

大数据分析工具Power BI(二):Power BI下载安装和模块介绍

首先在Microsoft官方网站上下载PowerBI Desktop,然后进行安装。id=58494点击"Next"后会弹出下载框,进行下载即可,下载好的PowerBI名称为"PBIDesktopSetup_x64.exe",也可以在"资料"中获取安装包,双击安装包即可安装。

Lansonli(蓝深李)的博客 2333

YOLOv11改进策略【卷积层】| 引入注意力卷积模块RFAConv,关注感受野空间特征 助力yolov11精度提升

RFAConv:创新空间注意力和标准卷积运算感受野空间特征是针对卷积核设计的,根据卷积核大小动态生成。以3×3卷积核为例,它由非重叠滑动窗口组成,每个窗口代表一个感受野滑块。

Limiiiing的博客 1834

2018-9-11日常作业:SAMBA搭建共享服务器

1.搭建匿名用户共享服务器 2.搭建用户认证共享服务器 要求: 1.不论是匿名用户还是用户认证共享,均要在客户机验证结果 2.用户认证共享需要映射系统用户为一个虚拟用户 配置环境 主机端 客户端 192.168.88.128 192.168.88.129 1.搭建匿名用户共享服务器 1.搭建前准备 [root@localhost ~]...

Empty_city_dreams的博客 882

Couldn‘t agree a key exchange algorithm(available:curve25519-sha256,curve25519-sha256@libssh.org解决方案

本文主要介绍了Couldn’t agree a key exchange algorithm(available:curve25519-sha256,curve25519-sha256@libssh.org解决方案,希望能对使用winscp的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案 2.1 方案一 2.2 方案二

weixin_43178406的博客 4万+

java samba 客户端

最近需用使用java访问linux下的共享目录,实现文件下载和上传, 由于linux共享文件主要采用两种方式,samba和NFS,samba是基于Microsoft的smb/cifs协议, NFS网络文件系统(Network File System)则是另一种协议. 对这两种方式的配置和实现代码如下:(配置在Ubuntu下完成)      一,samba         (1)配置: 

i_lovefish的专栏 7153

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

深度学习工具包 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&#39;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(&#39;DeepLearnToolbox&#39;));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(&#39;state&#39;,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&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,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 = &#39;sigm&#39;;%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, &#39;Too big error&#39;);```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(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;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)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;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, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% 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&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 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, &#39;Too big error&#39;);```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(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % 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, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);%% 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(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ubuntu 设置开机自动挂载smb共享文件夹

挂载共享目录//192.168.1.1/share,并指定用户名,密码(如共享目录无用户名密码,可去掉username参数,保留password参数,并且password="")其中,uid=ubuntu,gid=ubuntu参数作用为指定挂载共享文件夹所属的本地用户和用户组,如果不指定,默认为root:root。本地新建挂载目录,我指定为~/mount-test。编辑/etc/fstab文件,最后一行添加。1.命令行挂载smb共享目录。首先安装cifs-utils。保存后,可执行以下命令测试。

qq_41898224的博客 433

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

192.168.1.1路由器管理系统使用教程

192.168.1.1 是大多数家庭路由器的默认 IP 地址,用于访问路由器的管理控制台。通过这个管理系统,用户可以配置网络设置、管理连接设备、设置无线网络安全等。

2401_84119582的博客 9万+

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

samba服务的高级进阶配置

本文将学习一下几个方面的内容,将会结合具体的实验来一步步实现。 1、 用户账号的映射 2、 使用IP对客户端进行访问控制 3、 使用域名对客户端进行访问控制 4、 使用通配符对客户端进行访问控制 5、 设置samba的权限 6、 设置samba的隐藏共享 7、 Samba客户端的配置 8、 Samba的排错 Samba服务器的常规配置很容易就可以实现,但是并不能够满足企业的实际需

骆驼的专栏 1272

渗透网关路由器(192.168.1.1)—— 控制整个网络

这份 Nmap 扫描结果非常有价值,清晰暴露了网段内 4 台活跃主机的核心信息(系统、开放端口、服务版本),为后续渗透测试提供了明确目标和攻击方向。

2501_93842368的博客 1912

ImmortalWrt Samba服务器配置:家庭文件共享解决方案

你是否还在为家庭中多设备间的文件传输烦恼?手机里的照片想在电脑上编辑,电脑下载的电影想在电视上播放,却被各种数据线和复杂的操作步骤劝退?本文将带你通过ImmortalWrt系统搭建Samba服务器,实现家庭内所有设备的无线文件共享,让文件传输像访问本地文件夹一样简单。读完本文,你将掌握Samba服务的安装、配置、访问和安全优化方法,轻松构建家庭文件共享中心。 ## Samba服务简介 Samb...

gitblog_00905的博客 1452

java操作共享文件SMB问题处理

遇到的错误如下: java.net.UnknownHostException: at jcifs.UniAddress.getAllByName(UniAddress.java:315) at jcifs.smb.SmbFile.getFirstAddress(SmbFile.java:864) at jcifs.smb.SmbFile.connect(SmbFile.java:951)

zhh123sy001的专栏 3682

Java配置局域网内访问linux下共享文件夹的数据

使用java配置局域网内访问linux下共享文件夹的数据

Demon_666的博客 1462
上一篇: java将base64字符串的图片转换成本地图片、本地图片转base64字符串
下一篇: java 将对象转成Map
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址