Java : Convert formatted xml file to one line string

前端 未结 10 1437
时光取名叫无心
时光取名叫无心 2020-12-01 04:02

I have a formatted XML file, and I want to convert it to one line string, how can I do that.

Sample xml:



        
10条回答
  •  猫巷女王i
    2020-12-01 04:14

    In java 1.8 and above

    BufferedReader br = new BufferedReader(new FileReader(filePath));
    String content = br.lines().collect(Collectors.joining("\n"));
    

提交回复
热议问题