Java String Trim Right rightTrim(String[] values)

Here you can find the source of rightTrim(String[] values)

Description

right Trim

License

Open Source License

Declaration

public static String[] rightTrim(String[] values) 

Method Source Code

//package com.java2s;
/**//from ww w. j a v  a 2  s.  c o m
 * Copyright (c) 2015 SK holdings Co., Ltd. All rights reserved.
 * This software is the confidential and proprietary information of SK holdings.
 * You shall not disclose such confidential information and shall use it only in
 * accordance with the terms of the license agreement you entered into with SK holdings.
 * (http://www.eclipse.org/legal/epl-v10.html)
 */

public class Main {

    public static String[] rightTrim(String[] values) {
        isNull(values);
        StringBuffer b = null;

        for (int j = 0; j < values.length; j++) {
            b = new StringBuffer(values[j]);
            for (int k = b.length() - 1; k >= 0; k--) {
                if (b.charAt(k) == ' ') {
                    b.deleteCharAt(k);
                } else if (b.charAt(k) != ' ') {
                    break;
                }
            }
            values[j] = b.toString();
        }

        return values;
    }

    public static boolean isNull(String[] string) {
        if (string == null) {
            return true;
        }

        return false;
    }

    public static boolean isNull(Object object) {
        return (object == null);
    }
}

Related

  1. rightTrim(String str)
  2. rightTrim(String str)
  3. rightTrim(String str)
  4. rightTrim(String string)
  5. rightTrim(String value)
  6. rightTrim(StringBuilder pStringBuilder)
  7. rightTrimNewLineChars(String input)
  8. rightTrimSize(String s)
  9. rightTrimSlashes(String s)