on 12-19-2006 2:18 AM
Hi everyone,
I used FileUpload element to upload file to KM folder.<b> It works fine for the English filename, but fails to work for the non-English filename. (Chinese filename</b>). How do I encode the filename to be recognized by the FileUpload API. A piece of my code is as follows:
WDAttributeInfo attInfo = wdContext.nodeFileUpload().getNodeInfo().getAttribute("FileResource");
IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) attInfo.getModifiableSimpleType();
String mineType = binaryType.getMimeType().toString();
byte[] fileData = wdContext.currentFileUploadElement().getFileResource();
File file = new File(binaryType.getFileName());
/Create an output stream for writing to the temperory location/
FileOutputStream out = new FileOutputStream(file);
out.write(fileData);
out.flush();
out.close();
/From the temporary location read the file using an input stream/
FileInputStream fin = new FileInputStream(".//"+file);
<b>binaryType.getFileName() gives me the wrong encoding characters.</b>
Please advice me how to solve this....thanks a lot.
Zita
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Zita,
Try this...
String fileName = new String(binaryType.getFileName().getBytes(),"UTF-8");
File file = new File(fileName);
If charset <b>UTF-8</b> doesnt work then you can try <b>iso-2022-cn</b> which is for Chinese charset.
Regards
Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhilash,
Thank you for your reply, but none of them is working....
I tried:
fileName = new String(binaryType.getFileName().getBytes((String)System.getProperties().get("file.encoding")), "Big5");
fileName = new String(binaryType.getFileName().getBytes(), "Big5");
fileName = new String(binaryType.getFileName().getBytes(), "iso-2022-cn");
fileName = new String(binaryType.getFileName().getBytes(), "UTF-8");
Any other method???
thanks,
Zita
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.