FileOutputStream fos = new FileOutputStream(filename);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(new Date());
得到
获取编码:
String defaultCharsetName=Charset.defaultCharset().displayName();
System.out.println("defaultCharsetName:"+defaultCharsetName);
output: defaultCharsetName:UTF-8
Linux 平台(Centos)
vimrc设置:
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=gbk,utf-8,chinese,latin-1
set termencoding=utf-8
set encoding=utf-8
endif
尝试:
public static void FileWriterTest(String filename) throws IOException {
String s = "try";
String s1 = "agin";
FileWriter fw = new FileWriter(filename);
fw.write(s, 0, s.length());
fw.write(s1,0,s1.length());
fw.flush();
}
正常
请教是哪里的问题?Thanks
------解决思路----------------------
Object输出的本来就是字节数据,你硬要用记事本打开