public static void delaySave() {
final String objectStoreFolder ="D:\\obj\\";
System.out.println("Store Object Start..");
// Store Object 序列化对象
ObjectOutputStream out = null;
try {
out = new ObjectOutputStream(new FileOutputStream(
objectStoreFolder+ "objectFile.obj" + 0));
List list = new ArrayList(0);
for (int i = 0; i < 5000000; i++) {
if (((i+1) % 100000) == 0) {
out.writeObject(list);
out.close();
out = null;
list = null;
list = new ArrayList(0);
out = new ObjectOutputStream(new FileOutputStream(
objectStoreFolder+ "objectFile.obj" + ((i % 1000000) + 1)));
}
System.out.println(i);
list.add(new BigInteger("1000000"));
}
} catch (FileNotFoundException e) {
System.err.println(e.getMessage());
} catch (IOException e) {
System.err.println(e.getMessage());
}
finally{
if(null != out ){
try {
out.close();
out = null;
} catch (IOException e) {
// ignore
}
}
}
责任编辑:小草