1
2
3
4
5
6
7
8
9
10 package tsukuba_bunko.text;
11
12 /***
13 * 基本的な文字列操作のためのユーティリティクラスです。
14 * @author $Author: ppoi $
15 * @version $Revision: 1.1 $
16 */
17 public final class StringUtil {
18
19 /***
20 * 文字列の前後の不要な空白を除去します。
21 * @param text 処理対象の文字列
22 * @param voidToNull <code>true</code> の場合、処理結果が空文字列の場合に <code>null</code> を返し、それ以外の場合、そのまま処理結果を返す。
23 * @return 処理結果
24 */
25 public static String trimString( String text, boolean voidToNull )
26 {
27 if( text != null ) {
28 text = text.trim();
29 if( voidToNull && (text.length() == 0) ) {
30 text = null;
31 }
32 }
33 return text;
34 }
35 }