
//使用socket传输文件:
//下载:
InputStream ip=socket.getInputStream();
FileOutputStream f=new FileOutputStream ( "E://temp.jpg" );
byte [] b= new byte [10];
while ( ip.read ( b ) !=-1 )
{
f.write ( b );
}
//上传:
OutputStream op=socket.getOutputStream();
FileInputStream f=new FileInputStream ( "D://temp2.jpg" );
byte [] b=new byte[10];
while ( f.read ( b ) !=-1 )
{
op.write ( b );
}




初级程序员
by: 微微 发表于:2016-08-21 20:50:06 顶(0) | 踩(0) 回复
。。。。
回复评论