共享文件下载--SMB
来源:互联网 发布:淘宝客服常见刁蛮问题 编辑:程序博客网 时间:2024/05/19 05:01
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileInputStream;
import java.io.*;
/**
* need seven parameters
* account is used to access share folder
* password is used to access share folder
* ip specifies host in which share folder locates
* shareDir is the path of share folder
* file specifies the file supposed to be downloaded.
* localDir specifies the local directory for preserving files downloaded.
* localFile specifies the file name for downloaded files.
*/
public class ShareFileDownload {
public static void main(String[] args) {
if(args.length == 7){
String account = args[0].trim();
String password = args[1].trim() ;
String ip = args[2].trim();
String shareDir = args[3].trim() ;
String file = args[4].trim() ;
String localDir = args[5].trim();
String localFile = args[6].trim();
try {
String connStr = "smb://" + account + ":" + password + "@" + ip + "/" + shareDir + "/" + file ;
System.out.println(connStr);
SmbFile smbFile = new SmbFile(connStr);
//"smb://pz:pz521@111.111.111.111/share/1.txt");
int length = 1024*1024;
SmbFileInputStream in = new SmbFileInputStream(smbFile);
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(localDir + "/" + localFile));
byte[] buffer = new byte[length];
while ((in.read(buffer)) != -1) {
out.write(buffer);
buffer = new byte[length];
}
in.close();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}else{
System.out.println("Need seven parameters.");
}
}
}
- 共享文件下载--SMB
- Android smb共享文件的下载
- SMB实现共享文件(上传、下载)
- SMB实现共享文件(上传、下载)
- 共享文件上传--SMB
- smb协议共享文件
- smb文件共享实现
- smb文件共享
- SMB文件共享
- SMB 文件共享
- Linux Windows 文件共享smb
- java利用SMB共享文件进行局域网文件的下载及apk升级
- 基于SMB/JCIFS协议的共享文件上传和下载(局域网中共享文件获取文件)
- 小型ANET linux-smb文件共享
- smb服务器建立共享文件账号
- 基于SMB协议的共享文件读写
- IOS_使用SMB实现局域网文件共享
- iOS_使用SMB实现局域网文件共享
- 强烈推荐:对《30个提高Web程序执行效率的好经验》的理解
- Junit 简单示例
- 推荐:程序员特有的9个坏习惯
- Junit 简单示例(使用TestSuite)
- 获取本机IP
- 共享文件下载--SMB
- 共享文件上传--SMB
- 对于编程
- c++强制类型转换
- 确定基类有虚析构函数
- wishing...waiting
- 一些重要的算法
- 今天
- 基于Struts框架的简单的登录页面