import java.io.*;
import jcifs.smb.SmbFileOutputStream;
import jcifs.smb.SmbFile;
public class ShareFileUpload {
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 {
SmbFile smbFile = new SmbFile(
"smb://" + account + ":" + password + "@" + ip + "/" + shareDir + "/" + file);
//"smb://zp:zp521@111.111.111.111/share/1.txt");
int length = 1024*1024;
SmbFileOutputStream out = new SmbFileOutputStream(smbFile);
BufferedInputStream in = new BufferedInputStream(new FileInputStream(new File(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
最新推荐文章于 2023-06-23 19:08:36 发布