Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { private static final String WHITESPACE = " \n\t"; public static boolean onlyContainsWhitespace(String src) { for (int i = 0; i < src.length(); i++) { final char c = src.charAt(i); if (WHITESPACE.indexOf(c) == -1) { //found a character which isn't whitespace return false; } } return true; } }