开发者

java save list<JButton>

I'm having a problem creating a method to save a list of buttons in a file and then load them back into my program when it开发者_Go百科 starts again. Simply put, how do I save a list into a file and then load that file back up as a list again?


One possibility is to use:

FileOutputStream file = new FileOutputStream("filename");

ObjectOutputStream out   = new ObjectOutputStream(file);

Then you can use

out.writeObject(ArrayOfObjects[i]);

to save an element to the file. You will have to iterate over all elements of the list.

EDIT: I dont't know whether it is possible to use something like

out.writeObject(TheWholeList)

But you should definitely try it .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜