Java String Chomp chomp(String s)

Here you can find the source of chomp(String s)

Description

Returns the supplied string with any trailing '\n' removed.

License

Open Source License

Declaration

public static String chomp(String s) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*  w w  w. j  a va  2 s  . c  o m*/
     * Returns the supplied string with any trailing '\n' removed.
     */
    public static String chomp(String s) {
        if (s.length() == 0)
            return s;
        int l_1 = s.length() - 1;
        if (s.charAt(l_1) == '\n') {
            return s.substring(0, l_1);
        }
        return s;
    }

    /**
     * Returns the result of calling toString() on the supplied Object, but with
     * any trailing '\n' removed.
     */
    public static String chomp(Object o) {
        return chomp(o.toString());
    }
}

Related

  1. chomp(String in)
  2. chomp(String inStr)
  3. chomp(String options)
  4. chomp(String path)
  5. chomp(String s)
  6. chomp(String sd, String c)
  7. chomp(String str)
  8. chomp(String str)
  9. chomp(String str)