Here you can find the source of emptyString(final String string)
Parameter | Description |
---|---|
string | String to check |
public static boolean emptyString(final String string)
//package com.java2s; /******************************************************************************* * Copyright (c) 2015, 2017 Lablicate GmbH. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w ww.ja va 2 s . com * Dr. Alexander Kerner - initial API and implementation *******************************************************************************/ public class Main { /** * Check if a string is {@code null}, empty or contains only whitespaces. * * @param string * {@code String} to check * @return true, if this {@code String} is {@code null}, empty or contains * only whitespaces; false otherwise */ public static boolean emptyString(final String string) { if (string == null) return true; if (string.length() < 1) return true; if (string.matches("\\s+")) return true; return false; } }