要用不同的语言登录服务器说“عاتبوها.txt”,但它在服务器上显示“?????.txt”。
在服务器上写入日志文件的代码如下:
BufferedWriter bw = null;
FileWriter fw = null;
String label = "label test";
// this content comming dynamic value from another method.
String content = "هذا هو اختبار عينة يرجى اختبار";
// this content comming dynamic value from another method.
String room = "اختبار";
Date date = new Date();
try {
String dt = sdf.format(date);
//String convertedRoom = new String(room.getBytes("UTF-8"));
String fileName = room.concat("_").concat(dt).concat(".txt");
File f = new File(fileName);
if(!f.exists()) {
f.createNewFile();
f.setWritable(true);
}
fw = new FileWriter(fileName,true);
bw = new BufferedWriter(fw);
bw.write(content);
bw.flush();
} catch (IOException e) {
//e.printStackTrace();
} finally {
try {
if (bw != null)
bw.close();
if (fw != null)
fw.close();
} catch (IOException ex) {
//ex.printStackTrace();
}
}
现在日志生成在服务器上正常,日志文件上的数据在文件中也正常......但问题是文件名不是用另一种语言(如 arebic.txt)生成的,它显示 ?????????? _.txt...请帮忙。