在项目中,别人传给我一个对象列表 List 我这边接收并分析生成xml文件。 如下:public static String list2XML(List list) { root = new Element(sroot); mydocument = new Document(root); Element secondRoot = new Element("ceng"); Object[] o = (Object[])list.get(0); secondRoot.addContent(o[1].toString()); root.addContent(secondRoot); return xml2String(); }
private static String xml2String() { try { XMLOutputter outp = new XMLOutputter(" ",true,"iso8859-1"); //xmlFileName = new FileOutputStream("aa.xml"); File file = new File("d://www/aa.xml"); file.createNewFile(); outp.output(mydocument,new FileWriter(file)); //outp.output(mydocument,xmlFileName); String string = outp.outputString(mydocument); return string; } catch(Exception e) { e.printStackTrace(); return "error"; } }
为什么出不来值,并且海出错误呢?
|
|