【发布时间】:2018-01-18 03:22:53
【问题描述】:
如何将文件写入为 UTF8?我已经设置了系统属性,但没有工作。
下面是示例代码。
SmbFileOutputStream sfos = null;
try {
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(wipDomain,wipUsername,wipPassword);
System.setProperty("jcifs.encoding", "UTF8");
logger.info("Path: " +path);
SmbFile sFile = new SmbFile(path, auth);
sfos = new SmbFileOutputStream(sFile);
sfos.write(content.getBytes());
return true;
} catch (IOException e) {
logger.error(e.getMessage());
return false;
} finally {
if (sfos != null){
try {
sfos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
【问题讨论】: