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
Joined: May 06, 2004
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.
Joined: Feb 14, 2006
i am seeing ? in the string, i tried by removing encoding/decoding also. still its not wroking properly