基于SMB/JCIFS协议的共享文件上传和下载(局域网中共享文件获取文件)
来源:互联网 发布:电脑怎么卸载软件 编辑:程序博客网 时间:2024/05/19 03:21
import jcifs.smb.SmbFile;import jcifs.smb.SmbFileInputStream;import jcifs.smb.SmbFileOutputStream;import java.io.*;public class Test {public static void main(String[] args) {// TODO Auto-generated method stubsmbPut("smb://administrator:Xqx1234@192.168.0.249/share", "F:/spfws.7z");smbGet("smb://administrator:Xqx1234@192.168.0.249/share/spfws.7z", "D:/");}/** * 下载 * @param remoteUrl * @param localDir */public static void smbGet(String remoteUrl,String localDir){InputStream in = null;OutputStream out = null;try {SmbFile smbFile = new SmbFile(remoteUrl);String fileName = smbFile.getName();File localFile = new File(localDir+ File.separator+fileName);in = new BufferedInputStream(new SmbFileInputStream(smbFile));out = new BufferedOutputStream(new FileOutputStream(localFile));byte []buffer = new byte[1024];while((in.read(buffer)) != -1){out.write(buffer);buffer = new byte[1024];}} catch (Exception e) {e.printStackTrace();}finally{try {out.close();in.close();} catch (IOException e) {e.printStackTrace();}}}/** * 存储 * @param remoteUrl * @param localFilePath */public static void smbPut(String remoteUrl,String localFilePath){InputStream in = null;OutputStream out = null;try {File localFile = new File(localFilePath);String fileName = localFile.getName();SmbFile remoteFile = new SmbFile(remoteUrl+"/"+fileName);in = new BufferedInputStream(new FileInputStream(localFile));out = new BufferedOutputStream(new SmbFileOutputStream(remoteFile));byte []buffer = new byte[1024];while((in.read(buffer)) != -1){out.write(buffer);buffer = new byte[1024];}} catch (Exception e) {e.printStackTrace();}finally{try {out.close();in.close();} catch (IOException e) {e.printStackTrace();}}}}
http://iteye.blog.163.com/blog/static/1863080962012111155514179/
http://supercharles888.blog.51cto.com/609344/1344301
阅读全文
0 0
- 基于SMB/JCIFS协议的共享文件上传和下载(局域网中共享文件获取文件)
- 基于SMB协议的共享文件读写
- 基于SMB协议的共享文件读写
- 基于SMB协议的共享文件读写
- SMB实现共享文件(上传、下载)
- SMB实现共享文件(上传、下载)
- smb协议共享文件
- 共享文件上传--SMB
- 共享文件下载--SMB
- java基于SMB协议读取共享文件
- 基于SMB协议共享文件及文件夹的复制
- SMB协议的共享文件读写
- jcifs 文件共享操作
- JCIFS网络文件共享
- Android smb共享文件的下载
- java利用SMB共享文件进行局域网文件的下载及apk升级
- 使用JCIFS获取远程共享文件
- 使用JCIFS获取远程共享文件
- hdu 5873 Football Games
- 数组
- Struts中Resources cannot be null错误
- JZOJ5416. 【NOIP2017提高A组集训10.22】密码 DP
- android studio使用git第一次配置并上传代码到码云
- 基于SMB/JCIFS协议的共享文件上传和下载(局域网中共享文件获取文件)
- 3.1 (1)
- jmeter之如何减负-实现稳定超高并发测试(性能调优)
- java 语法层面调优
- 发善贾而沽哈爱人
- stdarg.h简介
- Application Insights使用
- Delphi winsock函数解析(一)
- 记一次RSA非对称算法的排坑经历