Java String Clip clip(final String s, final int leftClip, final int rightClip)

Here you can find the source of clip(final String s, final int leftClip, final int rightClip)

Description

Trims characters off the start and end of a string

License

Open Source License

Parameter

Parameter Description
s the string to trim
leftClip the number of characters off the left to trim
rightClip the number of characters off the right to trim

Return

the trimmed string

Declaration

public static String clip(final String s, final int leftClip, final int rightClip) 

Method Source Code

//package com.java2s;

public class Main {
    /**// w w  w .j a  v  a  2 s.c om
     * Trims characters off the start and end of a string
     * @param s the string to trim
     * @param leftClip the number of characters off the left to trim
     * @param rightClip the number of characters off the right to trim
     * @return the trimmed string
     */
    public static String clip(final String s, final int leftClip, final int rightClip) {
        return leftClip + rightClip >= s.length() ? "" : s.substring(leftClip, s.length() - rightClip);
    }
}

Related

  1. clip(String characterItem)
  2. clip(String str, int startChars)
  3. ClipObjectReferenceAddress(String p_fullObjectReference)
  4. clipString(String input, int numChars, boolean appendEllipses)