java System.getProperty("line.separator") 与 Android 的 "\n"

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12987451/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 11:03:39  来源:igfitidea点击:

System.getProperty("line.separator") Vs "\n" for Android

javaandroidlinuxhttpresponse

提问by Kalpesh Patel

My query is whether System.getProperty("line.separator")and "\n"for Android network operations are same. I mean to say. I will be getting line separated response from some server and so which is better to use System.getProperty("line.separator")or "\n"?

我的查询是System.getProperty("line.separator")"\n"Android网络操作是否相同。我的意思是说。我会越来越线分开的一些服务器的响应,因此这是更好地使用System.getProperty("line.separator")"\n"

reffred Carriage returns/line breaks with \n in strings in Androidbut still not sure with network operations.

refred回车/换行符在 Android 的字符串中使用 \n但仍然不确定网络操作。

回答by Deepak Bala

If you get line separated responses use BufferedReader.readLine()to read each line and then use System.getProperty("line.separator")if you want to insert the newline back into the String.

如果您获得行分隔响应BufferedReader.readLine(),则使用读取每一行,然后使用System.getProperty("line.separator")是否要将换行符插入回字符串中。