Here you can find the source of endsWithIgnoreWhiteSpace(String decl, String token)
public static boolean endsWithIgnoreWhiteSpace(String decl, String token)
//package com.java2s; import java.util.Stack; public class Main { /** @METHOD */ public static boolean endsWithIgnoreWhiteSpace(String decl, String token) { int index = decl.length() - 1; Stack<Character> stack = new Stack<Character>(); for (int i = 0; i < token.length(); index--) { if (decl.charAt(index) == ' ' || decl.charAt(index) == '\t') continue; char c = decl.charAt(index); stack.push(c);/*from w w w .j a v a 2 s . c o m*/ i++; } int stack_sz = stack.size(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < stack_sz; i++) { Character elem = stack.pop(); sb.append(elem.toString()); } if (token.equals(sb.toString())) return true; return false; } }