• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

saving data in a file based from Tree map

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi experts,
I need to save information from a treeMap that has as a key a GregorianCalendar and as a value a vector of a certain object.
When I wanted to implements is, I got the following error:
Error: can not write to file!Error: can not write to file!Error: theBills.Bill
that is in fact an exception!!
Here are the pieces of codes that are related to saving data:

public void save(){

DAO.openOutput();

Set <GregorianCalendar> keys = bills.keySet();
Vector<Bill> vb;
for(GregorianCalendar key: keys){
vb = bills.get(key);
for(Bill b: vb)
DAO.WriteObject(b);
}

DAO.closeFile();
}

////////////////////////////////////////////

public void WriteObject(Bill b){
try{
//openOutput();
out.writeObject(b);

}catch(IOException e){
System.err.print("Error: can not write to file!");

}
}

////////////////////
What do you think the error might be??
PS: I have made all the classes in the project implement Seriliazable.

Thank u so much for your help!!!


Dounia
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you think the error might be??

I have no idea, because in the catch-block you are not printing out any information regarding the exception. Try changing your catch-block to the following, which will give you more information:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic