First of all I searched the forum to see if someone has had the same problems that I have but did not find any.
Im using Apache FTPClient to connect and upload files and it works fine except for one thing. My application is running on a Linuxmachine which has UTF-8 as default encoding. What happens when I transfer a file stored with i.e. ISO-8859-1 the special chars get messed up. I should also mention that the server is on a windows machine.
This is my answer to why this happens. The storeFile-method take a InputStream which I cant encode(and therefore uses the default encoding. I have tried which Apaches ReaderInputStream bu it didnt work either).
One solution is to set Javas file encoing to ISO-8859-1 but i dont want to do that. Is there any way to dynamic set the encoding when transfering the file? In the same way as in the different reader classes?
FTP has 2 data modes, Binary and ASCII.
If you use binary to upload / download Text files, it is likely to destroy the characters.
"One of the best things you could do is to simplify a larger application into a smaller one by reducing its process and complexity - Fowler"
Joined: Jun 10, 2008
Thanks for you answer.
When I transfer the file in ascii mode the characters looks fine when the file I transfer is stored as UTF-8 but not when its a ISO stored file. This is when the file.encoding is set to the default value (UTF-8).
I think my solution is to set the file.encoding to Iso-8859-1. When its set to iso i can transfer the files binary and it works fine. But I will continue to search for another solution. Because I think I should be able to solve this in code.