Java examples for java.lang:String New Line
remove Carrier Return
//package com.java2s; public class Main { public static void main(String[] argv) { String string = "book\n\r2s.com"; System.out.println(removeCarrierReturn(string)); }/* w ww.jav a 2s. co m*/ public static String removeCarrierReturn(String string) { String result = ""; if (string != null) { int i = string.length(); int j = 0; char jump = '\n'; char tab = '\r'; while (j < i) { if ((string.charAt(j) != jump) && (string.charAt(j) != tab)) result = result + string.charAt(j); else result = result + ""; j++; } } return result; } }