Java String Chop chopIfMatch(StringBuilder sb, char ch)

Here you can find the source of chopIfMatch(StringBuilder sb, char ch)

Description

chop If Match

License

LGPL

Declaration

private static void chopIfMatch(StringBuilder sb, char ch) 

Method Source Code

//package com.java2s;
/*//from w  ww  .jav a 2 s  .co  m
 * JBoss, the OpenSource J2EE webOS
 * 
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 *
 * Portions of this file Copyright (C) 2013 Jeremy D Monin <jeremy@nand.net>
 */

public class Main {
    private static void chopIfMatch(StringBuilder sb, char ch) {
        if (sb.length() != 0 && sb.charAt(sb.length() - 1) == ch)
            sb.setLength(sb.length() - 1);
    }
}

Related

  1. chopCommentFromArgs(String[] args)
  2. chopExt(String orig)
  3. chopFirstComponent(String s)
  4. chopFractionalPart(float original, int no_of_digits )
  5. chopId(String name)
  6. chopLast(String value, int chars)
  7. chopLenghtyString(String title, int maxLen)
  8. chopLongLinesAtSpaces(int maxLineLenght, String text)
  9. chopNull(String str)