public static void writeDatFile(List<Object> list, String fileName)
throws Exception {
FileOutputStream fos = null;
ObjectOutputStream oos = null;
try {
fos = new FileOutputStream(fileName);
oos = new ObjectOutputStream(fos);
for (int i = 0; i < list.size(); i++) {
oos.writeObject(list.get(i));
oos.flush();
}
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
if (oos != null) {
oos.close();
}
if (fos != null) {
fos.close();
}
}
}
java写入.dat文件
最新推荐文章于 2021-02-25 09:05:33 发布