Saving contents of Stack using Object Serialization
posted 15 years ago
suppose I have a Stack class which acts as a runtime stack which I use to store stuff, how do i write all the contents of the stack to file using obj serialization? do i invoke writeObject() and just pass a Stack object in? or is there a catch to this? i tried this and even when i pop more stuff onto the stack, the output file remains the same size and the binary characters are only less than half a line long and doesnt seem right. whats wrong? also, for a stack that constantly receives data, how do u modify the exception bit so that if the stack overflows, the current data in the stack is saved to file via obj serialization? thanks.