I have a Hashtable<string,string>, in my program I want to record the values of the Hashtable to process later.
My question is: can we write object Hastable to a file? If so, how can we later load that file?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, using binary serialization (
ObjectOutputStream):Then you can read it using
ObjectInputStreamThe objects that you put inside the
Hashtable(or better –HashMap) have to implementSerializableIf you want to store the
Hashtablein a human-readable format, you can usejava.beans.XMLEncoder: