Here you can find the source of rightTrimNewLineChars(String input)
public static String rightTrimNewLineChars(String input)
//package com.java2s; /****************************************************************************** * Copyright (C) 2012-2013 Fabio Zadrozny and others * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from ww w .jav a2 s . co m * Fabio Zadrozny <fabiofz@gmail.com> - initial API and implementation * Jonah Graham <jonah@kichwacoders.com> - ongoing maintenance ******************************************************************************/ public class Main { /** * Removes the occurrences of the passed char in the end of the string. */ public static String rightTrimNewLineChars(String input) { int len = input.length(); int st = 0; int off = 0; char c; while ((st < len) && ((c = input.charAt(off + len - 1)) == '\r' || c == '\n')) { len--; } return input.substring(0, len); } }