最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
javs Socket传压缩文件,并文件打开接收到的文件
时间:2022-06-29 00:44:01 编辑:袖梨 来源:一聚教程网
public class TranFileServer {
public static void main(String[] args){
ServerSocket server;
Socket st;
try {
server = new ServerSocket(4000);
st = server.accept();
File receivedfile = new File( "src/2.rar ");
BufferedInputStream bin = new BufferedInputStream(st.getInputStream());
FileOutputStream fout = new FileOutputStream(receivedfile);
int i = bin.read();
while(i != -1){
fout.write(i);
i = bin.read();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
客户端:
public class TranFileClient {
public static void main(String[] args){
try {
Socket st = new Socket( "localhost ",4000);
File f = new File( "2.rar ");
FileInputStream fin = new FileInputStream(f);
BufferedOutputStream bout = new BufferedOutputStream(st.getOutputStream());
int size = fin.available();
for(int i = 0;i < size; i++){
bout.write(fin.read());
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
相关文章
- yandex登录入口一键直达-俄罗斯搜索引擎官网登录入口 12-16
- 热血江湖传兑换码大全 2025最新热血江湖传兑换码汇总 12-16
- 土豪漫画APP下载入口-官网全平台安全畅读 12-16
- 塞尔达无双封印战记逼近火山的危机怎么过 逼近火山的危机全流程图文攻略 12-16
- 51黑料最新地址-51黑料网每日吃瓜主页最新链接 12-16
- 土豪漫画秘密教学入口一键直达 免费下拉式在线畅看 12-16