WebService怎么传送文件呢,有人做过没,指点下

dtd89541 2011-08-25 09:05:48
WebService怎么传送文件呢,有人做过没,指点下
...全文
44 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
dtd89541 2011-08-26
  • 打赏
  • 举报
回复
谢谢ls,晚上加你Q
luohuijun619 2011-08-25
  • 打赏
  • 举报
回复
lz要是搞不定的话,可以找我,Q:359123279
luohuijun619 2011-08-25
  • 打赏
  • 举报
回复
package palmcity.cpndservice.tool;

import java.io.FileInputStream;
import java.io.RandomAccessFile;

public class ImageTool {
/**
* 图片BASE64 编码
*/
public static String getPicBASE64(String picPath) {
String content = null;
try {
FileInputStream fis = new FileInputStream(picPath);
byte[] bytes = new byte[fis.available()];
fis.read(bytes);
content = new sun.misc.BASE64Encoder().encode(bytes); // 具体的编码方法
fis.close();
// System.out.println(content.length());
} catch (Exception e) {
e.printStackTrace();
}
return content;
}

/**
* 对图片BASE64 解码
*
*/
public static void getPicFormatBASE64(String str, String picPath) {
try {
byte[] result = new sun.misc.BASE64Decoder().decodeBuffer(str
.trim());
RandomAccessFile inOut = new RandomAccessFile(picPath, "rw"); // r,rw,rws,rwd
// 用FileOutputStream亦可
inOut.write(result);
inOut.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
luohuijun619 2011-08-25
  • 打赏
  • 举报
回复
这个问题很简单,你用base64将图片,文件加码处理,接受方进行base64解码,再转换处理就OK了,

以前做彩信的时候,就是这样通过base64将图片处理,用string传过去

50,526

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧