您的位置:首页 > 运维架构 > Linux

java,Linux通用换行代码

2016-11-15 23:39 253 查看
lunix   下换行符只有:   \n

Mac   下换行符有:\r

windows  下换行方式: \r\n

代码可移植,换行统一写成 System.getProperty("line.separator")

public class newLineTest  
{  
    public static void main(String[] args)  
    {  
        String newLine = System.getProperty("line.separator");  
        System.out.println("我是第一行" + newLine + "我是第二行");  
    }  
}  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息