Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

FTP: Transfer is working but all TXT files have no content  RSS feed

 
Mirco H Schmidt
Greenhorn
Posts: 7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a program, which copies data from a ISERIES ftp server to my local folder c:\ temp. On this ftp server I have pdf files, doc files and txt files
The transfer to my local drive is working fine and all files appearing as expected.

Same program is picking up the data from my local drive and should copy same things to another FTP server.
This process is also working....but....

the TXT files have no content on my target FTP server and arriving with 0 kilo bytes, although they have contents on the source ftp server
and on the local c:\temp drive ?! The pdf and doc files are transferred correctly to the target ftp server.

Can anybody help and explain, why only TXT files have no content and arriving with 0 kilo bytes ?

Thanks Mirco

 
Greg Charles
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While FTP has separate binary and text transfer modes, this just covers translations of certain things, particularly newlines. However, there's nothing that I know of that would prevent a text file from being transferred in binary mode. It's not like FTP is going to analyze the bytes, realize they're text, not binary, and refuse to transfer them. I've never used the FTP class you're using though, so I don't know its quirks. You might try transferring the same files in binary, passive mode via the command line FTP client, and to the same destination machine and directory. Does that work?
 
Mirco H Schmidt
Greenhorn
Posts: 7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Greg,
have tested with ftp clients in binary mode and it is working.
The download to my local drive is ok, as I said. It is just,
when store() files back from local to FTP.
Same happens when I am doing it directly from FTP => FTP.

(I am using commons-net-3.0) to store the files to the FTP server
 
Mirco H Schmidt
Greenhorn
Posts: 7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
have made a bit progress on this.
It seems, that text files with a small file size, won't be copied.
When on the source ftp server the text file is e.g. 6 MB the file will be transferred.

When same program is picking up a text file with e.g. 6 KB, then it won't be transferred.

Reg
Mirco
 
Mirco H Schmidt
Greenhorn
Posts: 7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
setting the bufferSize to 1024 solved the issue!

Reg Mirco

 
Greg Charles
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I figured there must be something different about those files other them just being text files. Still, I don't really get why the buffer size makes a difference, unless a buffer isn't getting flushed somewhere. Even so, reducing the buffer size could lessen the problem, but probably not eliminate it. Maybe it's a matter of making the buffer size match between the FTP and the BufferedInputStream. I'm not sure why that would be though. Anyway, I'm glad you solved the problem!
 
dan Leon
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for me work with:

ftp.setBufferSize(1);
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!