【发布时间】:2017-10-31 19:05:51
【问题描述】:
我有一个 Web 服务提供商 (Java),它将一个 .doc 文件导入到 NotesDocument。名称中包含俄语字符的文件会出现问题 - 它们未正确传输。
例如,如果filename 等于Безымянный.doc,它将被转移为Áåçûìÿííûé.doc。
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";
如何解决这个问题?
【问题讨论】:
标签: java web-services encoding lotus-notes mime