My mistake.It has worked! I forgot deleting wrong code that i had before.
I put the entire code so that other developers can use it.
try {
//Create the XML Document structure
Document doc = new Document();
doc.setEncoding("ISO-8859-1");
XmlSerializer serializer = new KXmlSerializer();
Element principal = doc.createElement("","ListaRepartos");
listaRepartos.setAttribute(null,"id","1");
doc.addChild(Node.ELEMENT, principal);
//Create the output file which will be located in path
OutputStreamWriter writer=null;
FileConnection fc=null;
try{
String path="file:///C:/Data/Images/";
fc = (FileConnection) Connector.open(path+"oleola.xml", Connector.READ_WRITE);
if (!fc.exists())
fc.create();
OutputStream os = fc.openOutputStream();
writer = new OutputStreamWriter(os);
serializer.setOutput(writer);
doc.write(serializer);
}
finally {
writer.close();
fc.close();
}
}
catch (Exception exception) {
exception.printStackTrace();
}
Thanks guys!!
