62,614
社区成员
发帖
与我相关
我的任务
分享
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
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();
}
FileInputStream ios = new FileInputStream(filename);
ObjectInputStream iis = new ObjectInputStream(ios);
Date date = (Date) iis.readObject();
System.out.println(date);
正常读出