62,620
社区成员
发帖
与我相关
我的任务
分享
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException{
int expectedModCount = modCount;
s.defaultWriteObject();
s.writeInt(elementData.length);
for (int i=0; i<size; i++)
s.writeObject(elementData[i]);
if (modCount != expectedModCount) {
throw new ConcurrentModificationException();
}
}
File myObjectFile=new File("d:\\1.txt");
ObjectOutputStream oos;
oos=new ObjectOutputStream(new FileOutputStream(myObjectFile));
ArrayList<Integer> a=new ArrayList<Integer>();
a.add(1);
a.add(2);
oos.writeObject(a);
oos.close();
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException{
//...
s.defaultWriteObject();
s.writeInt(elementData.length);
for (int i=0; i<size; i++)
s.writeObject(elementData[i]);
//...
}
