File file = new File("D:/xml/PD20140924154_cunchu.xml"); StringBuilder sb = new StringBuilder(); FileInputStream fis=null; BufferedReader bf=null; try { fis = new FileInputStream(file); bf = new BufferedReader(new InputStreamReader(fis,"utf-8")); String str=""; while((str=bf.readLine())!=null){ sb.append(str); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println(sb.toString()); System.out.println("==============================================="); System.out.println(sb.toString().replaceAll("##", ">").replaceAll(" \\$\\$ ", "<"));
?<?xml version="1.0" encoding="utf-8" ?><Assets InventoryNumber="PD20140924154" TaskName="" BatchName="">