我有一個Web服務提供者(Java),它將.doc
文件導入到NotesDocument
。在名稱中帶有俄語字符的文件會出現問題 - 它們未正確傳輸。 例如,如果filename
將等於Безымянный.doc
,則它將被轉移爲Áåçûìÿííûé.doc
。在IBM Notes文檔中附件的名稱字符集/編碼
File directory = new File("C:\\Attachments 1C");
String filename = "Безымянный.doc"
String path = directory + "\\" + filename;
Stream outStream = sess.createStream();
sess.setConvertMIME(true);
MIMEEntity body = newDoc.createMIMEEntity("rtBody");
Stream inStream = sess.createStream();
if (inStream.open(path, "binary")) {
if (inStream.getBytes() > 0) {
do {
byte[] buffer = inStream.read(32767);
outStream.write(buffer);
} while (!inStream.isEOS());
inStream.close();
MIMEEntity child = body.createChildEntity();
String fileSuffix = path.substring(path.lastIndexOf(".")+1);
child.setContentFromBytes(outStream, fileSuffix, MIMEEntity.ENC_IDENTITY_BINARY);
MIMEHeader header = child.createHeader("Content-Disposition");
header.setHeaderVal("attachment; filename=\"" + filename + "\"");
header = child.createHeader("Content-ID");
header.setHeaderVal(path);
outStream.truncate();
}else
return "empty file";
}else
return "couldn't open the file";
如何解決這個問題?
我並不在這種情況下瀏覽器。該文件附加到IBM Notes環境中的NotesDocument。 – klendathu
我試過這個:String dispositionFileName = URLEncoder.encode(filename,「UTF-8」) - 不起作用。 – klendathu