卷曲会删除新行字符吗?
2022-09-01 00:06:38
我正在通过 curl 向我的服务发布一个包含多行列表的文本文件。当我在Spring MVC控制器中阅读请求的正文时,没有新的行字符,所有文本都在一行上。
卷曲会删除新行字符吗?有没有办法维护新的行字符,因为我需要它们来解析文本。以下是我用来阅读帖子正文的代码片段:
StringBuilder builder = new StringBuilder();
String line = null;
try {
BufferedReader reader = request.getReader();
while ((line = reader.readLine()) != null) {// this is just one line of text!
builder.append(line);
}
} catch (Exception e) {
//handle exception
}