简体   繁体   中英

How to write a “UTF-16” encoding File over FTP in java

I want to write a file directly in the FTP server using java and which needs to be in the UTF-16 format so that I can have support of latin,chinese,etc. characters .

Any suggestion will be of great help.

Thanks in advance.:))

Well, to start with it doesn't need to be UTF-16 to support all characters - I'd recommend UTF-8 instead of UTF-16.

However, basically you should transfer it as if it's a just a binary file (in binary mode in FTP). That way the bytes will be transferred with no textual interpretation so the two ends don't need to agree on an encoding at all.

To convert a String to or from UTF-8 and UTF-16 just use the String functions provided, there is a tutorial on them here:

http://docs.oracle.com/javase/tutorial/i18n/text/string.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM