Here you can find the source of getTrimedAttribute(Element elem, String attr_name)
static String getTrimedAttribute(Element elem, String attr_name)
//package com.java2s; /* it under the terms of the GNU General Public License as published by */ import org.w3c.dom.Element; public class Main { static String getTrimedAttribute(Element elem, String attr_name) { return trimOuterWhitespace(elem.getAttribute(attr_name)); }/* w w w . ja va2s . com*/ static String trimOuterWhitespace(String str) { if (str == null || str.length() == 0) { return str; } String ret = trimLeadingWhitespace(str); ret = trimTrailingWhitespace(ret); return ret; } static String trimLeadingWhitespace(String str) { if (str == null || str.length() == 0) { return str; } StringBuffer buf = new StringBuffer(str); for (;;) { if (buf.length() == 0 || Character.isWhitespace(buf.charAt(0)) == false) { break; } buf.deleteCharAt(0); } return buf.toString(); } static String trimTrailingWhitespace(String str) { if (str == null || str.length() == 0) { return str; } StringBuffer buf = new StringBuffer(str); for (;;) { int len = buf.length(); if (len == 0 || Character.isWhitespace(buf.charAt(len - 1)) == false) { break; } buf.deleteCharAt(len - 1); } return buf.toString(); } }