How to remove the carriage return from string while pasting content to Excel file

后端 未结 5 1745
逝去的感伤
逝去的感伤 2020-12-11 03:17

I have a problem while pasting my contents (or text) generated by Java code into excel. The problem is that my Java code generates a String with multiple lines, i.e. with li

5条回答
  •  执笔经年
    2020-12-11 03:38

    Try this =)

    String s1 = "this\r\nis a test";
    String s2 = s1.replaceAll("(\\r|\\n)", "");
    System.out.println(s2);
    

提交回复
热议问题