日期:2014-05-20 浏览次数:20942 次
?
?
FileConnection cfc = null;
OutputStream output = null;
try {
cfc = (FileConnection) Connector.open(filePath, Connector.READ_WRITE);
if (!cfc.exists()) {
cfc.create();
}
output = cfc.openOutputStream(cfc.fileSize());//从文件尾追加写
output.write(out.getBytes("UTF-8")); //必须用UTF-8编码,否则中文会乱码
output.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cfc != null)
try {
cfc.close();
} catch (IOException e) {
e.printStackTrace();
}
if (output != null)
try {
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
?
?
注意点:
?
?
?