• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why file's size is different?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,nice to meet you!
I want to know why remotefile's size is bigger than localfile's size?
help!Thank you very very much!

two method:

sun.net.ftp.FtpClient ftp;

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();
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you give us more clues? What are the sizes of the source and destination files (both cases)?

My first guess would be character encodings. With the first method, you're not using an encoding; you're reading/writing raw bytes. With the second, I believe that DataOutputStream will encode the character, though I cannot say for sure.

One thing's for sure, I'd recommend wrapping your network I/O with buffered streams.
 
robertb9527
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you,thank you,very thank you!

I do it:
ftp.binary;

that's ok!
 
reply
    Bookmark Topic Watch Topic
  • New Topic