How to read and write a HashMap to a file?

前端 未结 5 435
南笙
南笙 2020-12-09 04:13

I have the following HashMap:

HashMap fileObj = new HashMap();

ArrayList cols         


        
5条回答
  •  悲&欢浪女
    2020-12-09 04:37

    I believe you´re making a common mistake. You forgot to close the stream after using it!

     File file = new File("temp");  
     FileOutputStream f = new FileOutputStream(file);  
     ObjectOutputStream s = new ObjectOutputStream(f);          
     s.writeObject(fileObj);
     s.close();
    

提交回复
热议问题