stringtool.java

来自「这是一个学校老师和学生的管理系统,程序比较简单,但是几乎所有功能都可以实现,如果」· Java 代码 · 共 53 行

JAVA
53
字号
/**
 *******************************************************************************
 * StringTool.java
 *
 * (c) Copyright 2008 Hewlett-Packard Development Company, L.P.
 *
 *<Program Content>
 *  System Name : Students Management System
 *<Summarize>
 *  The file includes a class and  the main function of the class is to judge 
 *  whether a string is null or empty or made up by space characters.
 *<Update Record>
 *  2009-4-18    1.00    zhangliy
 *******************************************************************************
 */
package com.hp.eds.zhangliyuan.stuMan.util;

/**
 * The class main function is to judge whether a string is null or empty or made
 * up by space characters.
 * 
 * @author zhangliy
 * @version 1.0
 */
public class StringTool {
	/**
	 * judge whether a string is null or empty or made up by space characters.
	 * 
	 * @param string
	 *            -the string needs to be judged
	 * @return boolean(true:the string is null or empty or made up by space
	 *         characters;false:the string is not empty)
	 */
	public static boolean isStringEmpty(String string) {
		if (string == null || string.length() == 0) {
			// the string is null or its length is 0
			return true;
		}
		for (int i = 0; i < string.length(); i++) {
			if (string.charAt(i) == ' ') {
				// the character is space
				continue;
			} else {
				// the character is not space,return false
				return false;
			}
		}
		// the string is made up by space characters,return false
		return true;
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?