栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

您如何将发送到服务器的同一映像下载回客户端?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

您如何将发送到服务器的同一映像下载回客户端?

我会做这样的事情:

//服务器处理程序

 File file = new File(fileName);  FileInputStream fin = new FileInputStream(file);    // dout.writeUTF(fileName);    byte[] readData = new byte[1024];    fin.read(readData);     fin.close();   dout.write(readData, 0, readData.length);    dout.flush();      //ta.appendText("nImage Has Been Sent");  dout.flush();  fin.close();      }catch(IOException ex)       {System.out.println("Image ::"+ex);} }

//接收图片

if(extn.equals(".jpg") || extn.equals(".gif"))       {//give path to new file        File file = new File(".//Downloaded"+str);         FileOutputStream fout = new FileOutputStream(file);        //receive and save image from client         byte[] readData = new byte[1024];         int offset =0;         while((i = dis.read(readData,0,readData.length-offset)) != -1){   offset += i;        } fout.write(readData, 0, readData.length);  if(flag==1)  {  ta.append("Image Has Been Downloaded");  flag=0;  }    fout.flush();     fout.close();      } }


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/483832.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号