/** * 把xml字符串保存成xml文件 * @param path * @param context * @param charsetname */ public static void savexmlfile(String path,String context,String charsetname){ if(path==null)return; if("".equals(path))return; if(charsetname==null || "".equals(charsetname))charsetname="UTF-8"; FileOutputStream fos = null; try { fos = new FileOutputStream(path); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } OutputStreamWriter osw=null; try { osw = new OutputStreamWriter(fos,charsetname); } catch (UnsupportedEncodingException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } BufferedWriter bw=new BufferedWriter(osw); try { bw.append(context); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { bw.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }