Topic: 上传文件后与原来的大小不一样?求救!

  Print this page

1.上传文件后与原来的大小不一样?求救! Copy to clipboard
Posted by: robertb9527
Posted on: 2004-09-20 18:40

不知为什么用下面两个方法上传文件之后,都与原来的大小不一样,文件变大了!是加了空字符吗?那第二个方法应该不会出问题呀!
1. java.io.FileInputStream inFile = new FileInputStream(esPath);
sun.net.TelnetOutputStream outFile = ftp.put(remoteFile);

byte[] bufferDirect = new byte[1024];
while (true) {
int iBy = inFile.read(bufferDirect);
if (iBy < 0)
break;

outFile.write(bufferDirect, 0, iBy);

}

inFile.close();
outFile.close();



2. RandomAccessFile sendFile=new RandomAccessFile(esPath,"r");
sendFile.seek(0);
TelnetOutputStream outs=ftp.put(remoteFile);
DataOutputStream outputs=new DataOutputStream(outs);
int ch;
while(sendFile.getFilePointer()<sendFile.length()){

ch=sendFile.read();
outputs.write(ch);

}

outs.close();sendFile.close();


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923