xmlEncoder not writing in netBeans
Posted
by Greg
on Stack Overflow
See other posts from Stack Overflow
or by Greg
Published on 2010-05-19T20:11:17Z
Indexed on
2010/05/19
20:30 UTC
Read the original article
Hit count: 320
Hi,
I am trying to use the xmlEncoder to write to xml file in net-beans but it doesnt work.
Here is the call to the writing function:
dbManipulator.writeStudents(deps);
where
deps = new Hashtable<String, Department>();
dbManipulator = new DataBaseManipulator();
Department is an class-object I made, and here is writeStudents method which is located in the DataBaseManipulator class:
public void writeStudents(Hashtable<Integer, Student> students)
{
XMLEncoder encoder = null;
try
{
encoder = new XMLEncoder(new FileOutputStream(".\\test\\Students.xml"));
}
catch(Exception e){}
encoder.writeObject(students);
encoder.close();
}//end of function writeStudents()
Any ideas why it isnt working? I tried changing the hashtable to vector but still the xml file looks like that after the writing:
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.6.0_18" class="java.beans.XMLDecoder">
<object class="java.util.Hashtable"/>
</java>
Thanks in advance,
Greg
© Stack Overflow or respective owner