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 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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.