| JMS
客户端发送为:
public void run() {
try {
out = socket.getOutputStream();
dis = new DataInputStream(new BufferedInputStream(new FileInputStream(filetext)));
dos = new DataOutputStream(new BufferedOutputStream(out));
int num = 0;
byte[] buf = new byte[BUFFER];
while ((num = dis.read(buf,0,buf.length))!=-1) {
dos.write(num);
}
dos.flush();
out.close();
dis.close();
dos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
服务器接收为:
public void run(){
try {
File outFilename = new File("E:/JMS1/aa.zip");//指定目录

is = s.getInputStream();//获取网络输入流
os = s.getOutputStream();//输出流到网络
dis = new DataInputStream(new BufferedInputStream(is));
dos = new DataOutputStream(new FileOutputStream(outFilename));
byte[] bytes = new byte[8192];

while( (dis.read(bytes,0,bytes.length))!=-1 ){

dos.write(bytes);
}
dos.flush();
dos.close();
dis.close();
System.out.println("接收完成。");

this.getFilePath();//获取文件路径

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
服务器接收后提的文件比原文件大,请大家帮忙.怎样改......
评论
发表评论

您还没有登录,请登录后发表评论

yang52081
  • 浏览: 2324 次
  • 性别: Icon_minigender_1
  • 来自: 湖南省岳阳
  • 详细资料
搜索本博客
最近加入圈子
存档
最新评论
  • Oracle
    在Hibernate 中怎么样不让start with 不抛异常........ ...
    -- by yang52081
  • Oracle
    在Hibernate 中不能使用start吗???
    -- by yang52081
  • Oracle
    start with ?unexpected token: start sta ...
    -- by java_2006
  • jbpm
    请高手帮我看一下。。。
    -- by yang52081
  • JMS
    很简单啊,就是把Socket从客户端接收到的东西发到JMS消息队列呗 Spri ...
    -- by daquan198163