Java examples for java.lang:String Whitespace
remove All Previous Space from StringBuilder
//package com.java2s; public class Main { public static void removeAllPrevSpace(StringBuilder val, int endInd) { int startInd = getLastNonSpaceInd(val, endInd); val.delete(startInd + 1, endInd + 1); }//from w w w . j a va2s . c om public static int getLastNonSpaceInd(CharSequence val, int startInd) { int res = startInd; while (0 <= res) { char c = val.charAt(res); if (!Character.isSpaceChar(c) && !Character.isWhitespace(c)) break; --res; } return res; } public static int getLastNonSpaceInd(CharSequence val) { return getLastNonSpaceInd(val, val.length() - 1); } }