Java String Chop chopFirstComponent(String s)

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

Description

Returns the string s with the first component removed.

License

Open Source License

Parameter

Parameter Description
s The string to consider

Return

The part of s following the leftmost dot.

Declaration

public static String chopFirstComponent(String s) 

Method Source Code

//package com.java2s;

public class Main {
    /**/* w  w  w . j  a v a 2 s  .c  om*/
     * Returns the string <code>s</code> with the first component removed. For example,
     * the input "v.p1r.log.uid" would produce the result "p1r.log.uid". If <code>s</code>
     * contains no "." characters, the argument <code>s</code> is returned.
     *
     * @param s
     *            The string to consider
     * @return The part of s following the leftmost dot.
     */
    public static String chopFirstComponent(String s) {
        int dotIx = s.indexOf('.');
        return dotIx < 0 ? s : s.substring(1 + dotIx);
    }
}

Related

  1. ChopAllLf(String this_string, String chomp_off)
  2. ChopAllRt(String this_string, String chomp_off)
  3. chopBraces(String s)
  4. chopCommentFromArgs(String[] args)
  5. chopExt(String orig)
  6. chopFractionalPart(float original, int no_of_digits )
  7. chopId(String name)
  8. chopIfMatch(StringBuilder sb, char ch)
  9. chopLast(String value, int chars)