java对文件的操作的简单问题
发送文件:s=newSocket(fo.getIpString(),9334);byte[]by=newbyte[1024];fis=newFileInputStream...
发送文件:
s = new Socket(fo.getIpString(),9334);
byte[] by = new byte[1024];
fis = new FileInputStream(fo.getFileNameString());
while(fis.read(by)!=-1)
{
fos = (FileOutputStream) s.getOutputStream();
fos.write(by);
}
接收文件:
ss = new ServerSocket(9334);
s = ss.accept();
fos = new FileOutputStream(fileName);
byte[] by = new byte[1024];
int count = 0;
while(b)
{
fis = (FileInputStream) s.getInputStream();
while(fis.read(by)!=-1)
{
fos.write(by);
}
传输文件完毕后,文件总是多出几个几个字节
难道是多读取了换行符?
求解? 展开
s = new Socket(fo.getIpString(),9334);
byte[] by = new byte[1024];
fis = new FileInputStream(fo.getFileNameString());
while(fis.read(by)!=-1)
{
fos = (FileOutputStream) s.getOutputStream();
fos.write(by);
}
接收文件:
ss = new ServerSocket(9334);
s = ss.accept();
fos = new FileOutputStream(fileName);
byte[] by = new byte[1024];
int count = 0;
while(b)
{
fis = (FileInputStream) s.getInputStream();
while(fis.read(by)!=-1)
{
fos.write(by);
}
传输文件完毕后,文件总是多出几个几个字节
难道是多读取了换行符?
求解? 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询