我需要显示一个包含很多新行'\ n'的字符串,这些字符串需要替换为该字符串中的实际换行符。我该如何在android中做到这一点?
最佳答案
你可以用这个
StringWriter stringWriter = new StringWriter();
PrintWriter writer = new PrintWriter(stringWriter, true);
writer.println("line1");
writer.println("line2");
writer.println("line3");
useString(stringWriter.toString());
line1, line2 and line3
将以单独的行打印。