如何把bufferedinputstream 输出至bufferedoutputstre
答案:1 悬赏:70 手机版
解决时间 2021-04-19 20:38
- 提问者网友:放下
- 2021-04-19 07:07
如何把bufferedinputstream 输出至bufferedoutputstre
最佳答案
- 五星知识达人网友:鱼芗
- 2021-04-19 07:21
在服务器端设置代码:
BufferedInputStream infile = new BufferedInputStream(client.socket.getInputStream());
BufferedOutputStream outfile = new BufferedOutputStream(node.socket.getOutputStream());
byte[] b = new byte[1024];
int i = infile.read(b);
// FileOutputStream fos = new FileOutputStream(new File("e://Winter.jpg"));
try {
while (i!=-1) {
outfile.write(b, 0, i);
outfile.flush();
i = infile.read(b);
}
outfile.flush();
} catch (SocketException se) {
System.out.println("文件接受完毕");
}
BufferedInputStream infile = new BufferedInputStream(client.socket.getInputStream());
BufferedOutputStream outfile = new BufferedOutputStream(node.socket.getOutputStream());
byte[] b = new byte[1024];
int i = infile.read(b);
// FileOutputStream fos = new FileOutputStream(new File("e://Winter.jpg"));
try {
while (i!=-1) {
outfile.write(b, 0, i);
outfile.flush();
i = infile.read(b);
}
outfile.flush();
} catch (SocketException se) {
System.out.println("文件接受完毕");
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯