InputStream in = null;
OutputStream out = null;
try {
//获取图片
File localFile = new File("C:/testjpg");
String remotePhotoUrl = "smb://share:admin@11/sharedFolder/"; //存放图片的共享目录
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmssSSS_");
SmbFile remoteFile = new SmbFile(remotePhotoUrl + "/" + fmtformat(new Date()) + localFilegetName());
remoteFileconnect(); //尝试连接
in = new BufferedInputStream(new FileInputStream(localFile));
out = new BufferedOutputStream(new SmbFileOutputStream(remoteFile));
byte[] buffer = new byte[4096];
int len = 0; //读取长度
while ((len = inread(buffer, 0, bufferlength)) != -1) {
outwrite(buffer, 0, len);
}
outflush(); //刷新缓冲的输出流
}
catch (Exception e) {
String msg = "发生错误:" + egetLocalizedMessage();
Systemoutprintln(msg);
}
finally {
try {
if(out != null) {
outclose();
}
if(in != null) {
inclose();
}
}
catch (Exception e) {}
}
InputStream in = null ;
ByteArrayOutputStream out = null ;
try {
//创建远程文件对象
String remotePhotoUrl = "smb://share:admin@11/sharedFolder/testjpg";
SmbFile remoteFile = new SmbFile(remotePhotoUrl);
remoteFileconnect(); //尝试连接
//创建文件流
in = new BufferedInputStream(new SmbFileInputStream(remoteFile));
out = new ByteArrayOutputStream((int)remoteFilelength());
//读取文件内容
byte[] buffer = new byte[4096];
int len = 0; //读取长度
while ((len = inread(buffer, 0, bufferlength)) != - 1) {
outwrite(buffer, 0, len);
}
outflush(); //刷新缓冲的输出流
return outtoByteArray();
}
catch (Exception e) {
String msg = "下载远程文件出错:" + egetLocalizedMessage();
Systemoutprintln(msg);
}
finally {
try {
if(out != null) {
outclose();
}
if(in != null) {
inclose();
}
}
catch (Exception e) {}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有