• Post Reply Bookmark Topic Watch Topic
  • New Topic

saving data in a file based from Tree map

 
Dounia Kchiere
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15715
73
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!