try { FileWriter fw = new FileWriter(filePath + File.separator+ DateTools.getDateString(new Date(), "yyyyMMddHHmmss") + ".xml"); fw.write(xmlStr); fw.flush(); fw.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }