1.问题

windows平台的换行符为/r/n;

linux平台的换行符为/n;

java程序中如何将不同平台用户输入的换行符转换成特定系统的换行符.

2.解答

String userInputString = userInput;   
userInputString = userInputString.replaceAll ( "\r",  "" );   
userInputString = userInputString.replaceAll ( "\n",  "\\\\"+System.getPropert("line.separator")); 

<iframe frameborder="0" marginheight="0" marginwidth="0" border="0" id="alimamaifrm" name="alimamaifrm" scrolling="no" height="60px" width="250px" style="width:250px;height:60px" src="http://p.alimama.com/code.php?t=2&i=mm_10046837_140429_140019&w=250&h=60&sz=13&bgc=FFFFFF&bdc=E6E6E6&tc=0000FF&lc=008000&dc=000000"></iframe>