Hi, i am Java beginner. I know how to write and read text to and from a text file using FileWriter and FileReader. However, they are not capable of writing and reading object to and from a file. What classes should i use to achieve this goal? please help.
To write an object to a file (serialization), you use ObjectOutputStream wrapping a FileOutputStream object. To read the object back from the file (deserialization), you use ObjectInputStream wrapping a FileInputStream object. The object to be written to the file must implement the Serializable interface.
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: