Here you can find the source of zeroUnPad(String s)
Parameter | Description |
---|---|
s | - original string |
public static String zeroUnPad(String s)
//package com.java2s; /*// w ww . j av a2 s. co m * jPOS Project [http://jpos.org] * Copyright (C) 2000-2019 jPOS Software SRL * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Left unPad with '0' * @param s - original string * @return zero unPadded string */ public static String zeroUnPad(String s) { return unPadLeft(s, '0'); } /** * Unpad from left. * @param s - original string * @param c - padding char * @return unPadded string. */ public static String unPadLeft(String s, char c) { int fill = 0, end = s.length(); if (end == 0) return s; while (fill < end && s.charAt(fill) == c) fill++; return fill < end ? s.substring(fill, end) : s.substring(fill - 1, end); } }