This week's giveaways are in the MongoDB and Jobs Discussion forums. We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line! See this thread and this one for details.
Hi All, I am getting string value from one FTP server (this holds name of the file, and we are using Apache FTP API to get filenames), while creating a file in local maching with same name its not creating with japanese characters, its puting some junk charcters. Please help me in creating file with same name. I am using following code to get file name and to create new file
String sFilename = ftpFile.getName(); // ftpFile is apache FTPFile object String jpName = new String(sFilename.getBytes("UTF-8"),Charset.forName("SJIS")); File targetFile = new File(jpName); targetFile.createNewFile();
but this code is not working properly
Nuthan
Alan Moore
Ranch Hand
Joined: May 06, 2004
Posts: 262
posted
0
You shouldn't need to do any conversions. The FTP client should have converted the name to a valid Java string, and the File class should convert that to the encoding that's expected by the operating system.
What kind of garbage characters are you seeing? If it's question marks (?) you have an encoding problem, but if you see little boxes, it means the font you're using doesn't support those characters.
By the way, never do this: Unless the string consists entirely of seven-bit ASCII characters, that command is guaranteed to produce garbage. And if it is pure ASCII, the command will have no effect.
nuthan kumar
Ranch Hand
Joined: Feb 14, 2006
Posts: 47
posted
0
i am seeing ? in the string, i tried by removing encoding/decoding also. still its not wroking properly
actual file name 1-計画.tif and while trying to print that name its printing 1-??.tif
David Balažic
Ranch Hand
Joined: May 15, 2008
Posts: 83
posted
0
Print the name in some SWING GUI element (like JButton or JLabel), as the Windows command prompt does not support Unicode. Also print the string after each manipulation, to see where it breaks.