org.apache.commons.lang
クラス StringUtils

java.lang.Object
  拡張org.apache.commons.lang.StringUtils

public class StringUtils
extends Object

共通的な String に対する処理ルーチンです。

Common String manipulation routines.

オリジナルは Turbine と GenerationJavaCore ライブラリです。

Originally from Turbine and the GenerationJavaCore library.

バージョン:
$Id: StringUtils.java,v 1.1.1.1 2004/02/13 10:02:04 hioki Exp $
作成者:
Jon S. Stevens, Daniel Rall, Greg Coladonato, Henri Yandell, Ed Korthof, Rand McNeely, Stephen Colebourne, Fredrik Westermarck
翻訳者:
日置 聡
翻訳状況:
初稿(校正者募集中)
翻訳更新日:
2003/08/12

コンストラクタの概要
StringUtils()
          StringUtils のインスタンスは一般的なプログラムからは生成すべきではありません。
 
メソッドの概要
static String capitalise(String str)
          文字列の先頭を大文字にします。
static String capitaliseAllWords(String str)
          文字列内の全ての単語の先頭を大文字にします。
static String center(String str, int size)
          指定された文字列が中心に配置された、指定された長さの文字列を返します。
static String center(String str, int size, String delim)
          指定された文字列が中心に配置された、指定された長さの文字列を返します。
static String chomp(String str)
          (文字列の)最後の改行と、その後ろに続く全ての文字列を削除します。
static String chomp(String str, String sep)
          最後に見つかった指定された文字列とその後ろに続く全ての文字列を削除し返します。
static String chompLast(String str)
          文字列の末尾が改行だった場合のみ、改行を削除します。
static String chompLast(String str, String sep)
          文字列の末尾が指定された文字列だった場合にのみ、末尾のこの文字列を削除します。
static String chop(String str)
          文字列の最後の1文字を削除し返します。
static String chopNewline(String str)
          文字列の最後が \n たった場合にこれを削除します。
static String clean(String str)
          指定された文字列の最初と最後の空白を削除します。
static String concatenate(Object[] array)
          配列内のの要素を一つの文字列に連結します。
static boolean containsOnly(String str, char[] valid)
          文字列が指定された文字だけで構成されているかをチェックします。
static int countMatches(String str, String sub)
          文字列の中に指定された文字列がいくつあるかを返します。
static String defaultString(String str)
          渡された文字列をチェックし、null だった場合には空の文字列を返します。
static String defaultString(String str, String defaultString)
          渡された文字列をチェックし、null だった場合には指定されたデフォルトの文字列を返します。
static String deleteSpaces(String str)
          文字列から全ての空白文字を削除します。
static String deleteWhitespace(String str)
          文字列から全ての空白(whitespace)を削除します。
static boolean equals(String str1, String str2)
          2つの文字列を比較して、等しい場合に true を返します。
static boolean equalsIgnoreCase(String str1, String str2)
          2つの文字列を比較して、大文字と小文字を区別せずに等しい場合に true を返します。
static String escape(String str)
          文字列の中の全ての値をエスケープします。
static String getChomp(String str, String sep)
          最後に見つかった指定された文字列の前の部分を全て削除し返します。
static int getLevenshteinDistance(String s, String t)
          2つの文字列の間の Levenshtein 距離を調べます。
static String getNestedString(String str, String tag)
          同じ文字列の間に挟まれ、ネストされた文字列を返します。
static String getNestedString(String str, String open, String close)
          2つの文字列の間に挟まれ、ネストされた文字列を返します。
static String getPrechomp(String str, String sep)
          最初に見つかった指定された文字列より後ろを全て削除し返します。
static int indexOfAny(String str, String[] searchStrs)
          この文字列内で、指定された部分文字列のセットうちのどれかが最初に出現する位置のインデックスを返します。
static boolean isAlpha(String str)
          文字列がユニコードの汎用文字だけで構成されているかをチェックします。
static boolean isAlphanumeric(String str)
          文字列がユニコードの汎用文字と数字だけで構成されているかをチェックします。
static boolean isAlphanumericSpace(String str)
          文字列がユニコードの汎用文字と数字とスペース(' ')だけで構成されているかをチェックします。
static boolean isAlphaSpace(String str)
          文字列がユニコードの汎用文字とスペース(' ')だけで構成されているかをチェックします。
static boolean isEmpty(String str)
          (トリムされた)文字列が null 、または空(長さが0)であるかチェックします。
static boolean isNotEmpty(String str)
          文字列が null でなく、空(長さが0)でないかチェックします。
static boolean isNumeric(String str)
          文字列がユニコードの数字だけで構成されているかをチェックします。
static boolean isNumericSpace(String str)
          文字列がユニコードの数字とスペース(' ')だけで構成されているかをチェックします。
static String join(Iterator iterator, String separator)
          イテレータ内のの要素を一つの文字列に連結します。
static String join(Object[] array, String separator)
          配列内のの要素を一つの文字列に連結します。
static int lastIndexOfAny(String str, String[] searchStrs)
          この文字列内で、指定された部分文字列のセットうちのどれかが最後に出現する位置のインデックスを返します。
static String left(String str, int len)
          指定された文字列の左側から指定された長さの部分文字列を取得します。
static String leftPad(String str, int size)
          指定された長さになるまで文字列の左側(先頭)をスペースで埋めます。
static String leftPad(String str, int size, String delim)
          指定された長さになるまで文字列の左側(先頭)を指定された文字列で埋めます。
static String lowerCase(String str)
          文字列内の大文字を小文字に変換します。
static String mid(String str, int pos, int len)
          文字列の指定された開始位置から指定された長さの文字列を取得します。
static String overlayString(String text, String overlay, int start, int end)
          文字列内の指定されたインデックスの場所を指定された文字列で上書きします。
static String prechomp(String str, String sep)
          最初に見つかった指定された文字列までを削除し、その後ろに続く文字列を返します。
static String repeat(String str, int repeat)
          指定された文字列を指定された回数繰り返し作成された文字列を返します。
static String replace(String text, String repl, String with)
          対象の文字列内の全ての指定された文字列(repl)を指定された文字列(eith)に変換します。
static String replace(String text, String repl, String with, int max)
          対象の文字列内の指定された文字列(repl)を先頭から max の回数分、指定された文字列(eith)に変換します。
static String replaceOnce(String text, String repl, String with)
          対象の文字列内で最初に見つかった指定された文字列(repl)を指定された文字列(eith)に変換します。
static String reverse(String str)
          文字列内の並び順を逆にします。
private static void reverseArray(Object[] array)
          配列の並び順を逆にします。
static String reverseDelimitedString(String str, String delimiter)
          指定された区切り文字で文字列を分割し、その並び順を逆にします。
static String right(String str, int len)
          指定された文字列の右側から指定された長さの部分文字列を取得します。
static String rightPad(String str, int size)
          指定された長さになるまで文字列の右側(末尾)をスペースで埋めます。
static String rightPad(String str, int size, String delim)
          指定された長さになるまで文字列の右側(末尾)を指定された文字列で埋めます。
static String[] split(String str)
          文字列を空白を区切り文字として配列にします。
static String[] split(String text, String separator)
           
static String[] split(String str, String separator, int max)
          文字列を指定された区切り文字を使用してて配列にします。
static String strip(String str)
          文字列の前後から空白を削除します。
static String strip(String str, String delim)
          文字列の前後から指定された文字列を削除します。
static String[] stripAll(String[] strs)
          配列の中の全ての文字列の前後から空白を削除します。
static String[] stripAll(String[] strs, String delimiter)
          配列の中の全ての文字列の前後から指定された文字列を削除します。
static String stripEnd(String str, String strip)
          文字列の最後から指定された文字列を削除します。
static String stripStart(String str, String strip)
          文字列の最初から指定された文字列を削除します。
static String substring(String str, int start)
          指定された文字列の部分文字列を例外を発生させることなく取得します。
static String substring(String str, int start, int end)
          指定された文字列の部分文字列を例外を発生させることなく取得します。
static String swapCase(String str)
          大文字と小文字を入れ替えます。
static String trim(String str)
          指定された文字列の最初と最後の空白を削除します。
static String uncapitalise(String str)
          文字列の先頭を小文字にします。
static String upperCase(String str)
          文字列内の小文字を大文字に変換します。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

StringUtils

public StringUtils()
StringUtils のインスタンスは一般的なプログラムからは生成すべきではありません。 代わりに StringUtils.trim(" foo "); というように使用すべきです。 このコンストラクタは、処理に JavaBean インスタンスを必要とするツールのために public になっています。
StringUtils instances should NOT be constructed in standard programming. Instead, the class should be used as StringUtils.trim(" foo ");. This constructor is public to permit tools that require a JavaBean instance to operate.

メソッドの詳細

clean

public static String clean(String str)
指定された文字列の最初と最後の空白を削除します。 null が渡された場合には空の文字列を返します。
Removes control characters, including whitespace, from both ends of this string, handling null by returning an empty string.

パラメータ:
str - チェックする文字列
the string to check
戻り値:
トリムされた文字列(必ずnullではない)
the trimmed text (never null)
関連項目:
String.trim()

trim

public static String trim(String str)
指定された文字列の最初と最後の空白を削除します。 null が渡された場合には null を返します。
Removes control characters, including whitespace, from both ends of this string, handling null by returning null.

パラメータ:
str - チェックする文字列
the string to check
戻り値:
トリムされた文字列(または null)
the trimmed text (or null)
関連項目:
String.trim()

deleteSpaces

public static String deleteSpaces(String str)
文字列から全ての空白文字を削除します。 推奨されないメソッド Character.isSpace で定義されている {' ', '\t', '\r', '\n', '\b'} を空白文字として認識します。
Deletes all 'space' characters from a String. Spaces are defined as {' ', '\t', '\r', '\n', '\b'} in line with the deprecated Character.isSpace

パラメータ:
str - 空白文字を削除する対象となる文字列
String target to delete spaces from
戻り値:
空白文字が削除された文字列
the text without spaces
例外:
NullPointerException

deleteWhitespace

public static String deleteWhitespace(String str)
文字列から全ての空白(whitespace)を削除します。 空白(whitespace) は Character.isWhitespace で定義されています。
Deletes all whitespace from a String. Whitespace is defined by Character.isWhitespace

パラメータ:
str - 空白を削除する対象となる文字列
String target to delete whitespace from
戻り値:
空白が削除された文字列
the text without whitespace
例外:
NullPointerException

isNotEmpty

public static boolean isNotEmpty(String str)
文字列が null でなく、空(長さが0)でないかチェックします。
Checks if a String is non null and is not empty (length > 0).

パラメータ:
str - チェックする文字列
the string to check
戻り値:
文字列が null でなく、長さが0でない場合に true
true if the String is non-null, and not length zero

isEmpty

public static boolean isEmpty(String str)
(トリムされた)文字列が null 、または空(長さが0)であるかチェックします。
Checks if a (trimmed) String is null or empty.

パラメータ:
str - チェックする文字列
the string to check
戻り値:
true 文字列が null 、またはトリムされて長さが0の場合に true
true if the String is null, or length zero once trimmed

equals

public static boolean equals(String str1,
                             String str2)
2つの文字列を比較して、等しい場合に true を返します。 null は例外を発生せずに扱われます。2つの null の比較は等しいと判断されます。 大文字と小文字は区別されます。
Compares two Strings, returning true if they are equal. Nulls are handled without exceptions. Two null references are considered equal. Comparison is case sensitive.

パラメータ:
str1 - 最初の比較対照となる文字列
the first string
str2 - 次の比較対照となる文字列
the second string
戻り値:
true 大文字小文字を意識して文字列が等しい場合、または両方とも null の場合
true if the Strings are equal, case sensitive, or both null
関連項目:
String.equals(Object)

equalsIgnoreCase

public static boolean equalsIgnoreCase(String str1,
                                       String str2)
2つの文字列を比較して、大文字と小文字を区別せずに等しい場合に true を返します。 null は例外を発生せずに扱われます。2つの null の比較は等しいと判断されます。 大文字と小文字は区別されません。
Compares two Strings, returning true if they are equal ignoring case. Nulls are handled without exceptions. Two null references are considered equal. Comparison is case insensitive.

パラメータ:
str1 - 最初の比較対照となる文字列
the first string
str2 - 次の比較対照となる文字列
the second string
戻り値:
true 大文字小文字を意識せず文字列が等しい場合、または両方とも null の場合
true if the Strings are equal, case insensitive, or both null
関連項目:
String.equalsIgnoreCase(String)

indexOfAny

public static int indexOfAny(String str,
                             String[] searchStrs)
この文字列内で、指定された部分文字列のセットうちのどれかが最初に出現する位置のインデックスを返します。 該当する文字がこの文字列内にない場合は、-1 が返されます。
Find the earliest index of any of a set of potential substrings. Null string will return -1.

パラメータ:
str - チェックする文字列
the string to check
searchStrs - 検索する文字列の一覧
the strings to search for
戻り値:
検索する文字列のどれかが最初に出現する位置
the earliest index of any of the strings
例外:
NullPointerException - searchStrs[i] のうちのどれかが null だった場合
if any of searchStrs[i] is null

lastIndexOfAny

public static int lastIndexOfAny(String str,
                                 String[] searchStrs)
この文字列内で、指定された部分文字列のセットうちのどれかが最後に出現する位置のインデックスを返します。 該当する文字がこの文字列内にない場合は、-1 が返されます。
Find the latest index of any of a set of potential substrings. Null string will return -1.

パラメータ:
str - チェックする文字列
the string to check
searchStrs - 検索する文字列の一覧
the strings to search for
戻り値:
検索する文字列のどれかが最後に出現する位置
the last index of any of the strings
例外:
NullPointerException - searchStrs[i] のうちのどれかが null だった場合
if any of searchStrs[i] is null

substring

public static String substring(String str,
                               int start)
指定された文字列の部分文字列を例外を発生させることなく取得します。 マイナスの開始位置の指定は文字列の最後から開始位置を遡って指定する場合に使用されます。
Gets a substring of the specified string avoiding exceptions. A negative start position can be used to start n characters from the end of the string.

パラメータ:
str - 部分文字列の取得s対象となる文字列
the string to get the substring from
start - 部分文字列の開始位置。 マイナスの値は文字列の最後からその値だけ戻ることを意味します
the position to start from, negative means count back from the end of the string by this many characters
戻り値:
開始位置からの部分文字列
substring from start position

substring

public static String substring(String str,
                               int start,
                               int end)
指定された文字列の部分文字列を例外を発生させることなく取得します。 マイナスの開始/終了位置の指定は文字列の最後から開始/終了位置を遡って指定する場合に使用されます。
Gets a substring of the specified string avoiding exceptions. A negative start position can be used to start/end n characters from the end of the string.

パラメータ:
str - 部分文字列の取得s対象となる文字列
the string to get the substring from
start - 部分文字列の開始位置。 マイナスの値は文字列の最後からその値だけ戻ることを意味します
the position to start from, negative means count back from the end of the string by this many characters
end - 部分文字列の終了位置。 マイナスの値は文字列の最後からその値だけ戻ることを意味します
the position to end at (exclusive), negative means count back from the end of the string by this many characters
戻り値:
開始位置から終了位置までの部分文字列
substring from start position to end positon

left

public static String left(String str,
                          int len)
指定された文字列の左側から指定された長さの部分文字列を取得します。 文字列の長さが指定された長さに満たなかった場合、文字列に null が指定された場合には、 例外は発生せず、元の文字列を返します。
Gets the leftmost n characters of a string. If n characters are not available, or the string is null, the string will be returned without an exception.

パラメータ:
str - 左側の部分文字列を取得する対象となる文字列
the string to get the leftmost characters from
len - 部分文字列の長さ
the length of the required string
戻り値:
左側の部分文字列
leftmost characters
例外:
IllegalArgumentException - len にマイナスの値が指定された場合
if len is less than zero

right

public static String right(String str,
                           int len)
指定された文字列の右側から指定された長さの部分文字列を取得します。 文字列の長さが指定された長さに満たなかった場合、文字列に null が指定された場合には、 例外は発生せず、元の文字列を返します。
Gets the rightmost n characters of a string. If n characters are not available, or the string is null, the string will be returned without an exception.

パラメータ:
str - 右側の部分文字列を取得する対象となる文字列
the string to get the rightmost characters from
len - 部分文字列の長さ
the length of the required string
戻り値:
右側の部分文字列
rightmost characters
例外:
IllegalArgumentException - len にマイナスの値が指定された場合
if len is less than zero

mid

public static String mid(String str,
                         int pos,
                         int len)
文字列の指定された開始位置から指定された長さの文字列を取得します。 指定された長さ分の文字列が取得できなかった場合には例外を発生せずに取得できた分だけの文字列を返します。 指定された文字列が null だった場合には null を返します。
Gets n characters from the middle of a string. If n characters are not available, the remainder of the string will be returned without an exception. If the string is null, null will be returned.

パラメータ:
str - 部分文字列を取得する対象となる文字列
the string to get the characters from
pos - 開始位置
the position to start from
len - 部分文字列の長さ
the length of the required string
戻り値:
取得された部分文字列
the leftmost characters
例外:
IndexOutOfBoundsException - pos が範囲外である場合
if pos is out of bounds
IllegalArgumentException - len にマイナスの値が指定された場合
if len is less than zero

split

public static String[] split(String str)
文字列を空白を区切り文字として配列にします。 区切り文字は配列内の文字列には含まれません。
Splits the provided text into a list, using whitespace as the separator. The separator is not included in the returned String array.

パラメータ:
str - パースされる文字列
str the string to parse
戻り値:
パースされた文字列の配列
an array of parsed Strings

split

public static String[] split(String text,
                             String separator)
関連項目:
split(String, String, int)

split

public static String[] split(String str,
                             String separator,
                             int max)
文字列を指定された区切り文字を使用してて配列にします。 区切り文字は配列内の文字列には含まれません。 文字列を区切る際の最大数を指定することができます。 区切り文字に null 画指定された場合には空白が使用されます。
Splits the provided text into a list, based on a given separator. The separator is not included in the returned String array. The maximum number of splits to perfom can be controlled. A null separator will cause parsing to be on whitespace.

このメソッドは( StringTokenizer がするような) トークンの一覧を作成する処理の代わりに、すばやく文字列を配列に変換するのに有用です。

This is useful for quickly splitting a string directly into an array of tokens, instead of an enumeration of tokens (as StringTokenizer does).

パラメータ:
str - パースされる文字列
str the string to parse
separator - 区切り文字として使用される文字。 null の場合には空白を使用
Characters used as the delimiters. If null, splits on whitespace.
max - 配列の最大の大きさ。 0またはマイナスの値は制限がないことを意味します。
The maximum number of elements to include in the list. A zero or negative value implies no limit.
戻り値:
パースされた文字列の配列
an array of parsed Strings

concatenate

public static String concatenate(Object[] array)
配列内のの要素を一つの文字列に連結します。 join メソッドとの違いは、連結時の区切り文字をもたないことです。
Concatenates elements of an array into a single string. The difference from join is that concatenate has no delimiter.

パラメータ:
array - 連結の対象となる配列
the array of values to concatenate.
戻り値:
連結された文字列
the concatenated string.

join

public static String join(Object[] array,
                          String separator)
配列内のの要素を一つの文字列に連結します。 区切り文字に null が指定された場合には空の文字列として扱われ いかなるデリミターも、リストの前後には加えられません。
Joins the elements of the provided array into a single string containing the provided list of elements. No delimiter is added before or after the list. A null separator is the same as a blank String.

パラメータ:
array - 連結の対象となる配列
the array of values to join together
separator - 区切り文字
the separator character to use
戻り値:
連結された文字列
the joined String

join

public static String join(Iterator iterator,
                          String separator)
イテレータ内のの要素を一つの文字列に連結します。 区切り文字に null が指定された場合には空の文字列として扱われ いかなるデリミターも、リストの前後には加えられません。
Joins the elements of the provided iterator into a single string containing the provided elements. No delimiter is added before or after the list. A null separator is the same as a blank String.

パラメータ:
iterator - 連結の対象となるイテレータ
the iterator of values to join together
separator - 区切り文字
the separator character to use
戻り値:
連結された文字列
the joined String

replaceOnce

public static String replaceOnce(String text,
                                 String repl,
                                 String with)
対象の文字列内で最初に見つかった指定された文字列(repl)を指定された文字列(eith)に変換します。
Replace a string with another string inside a larger string, once.

パラメータ:
text - 入れ替え対象の文字列を含むテキスト
text to search and replace in
repl - 入れ替え対象となる文字列
String to search for
with - 入れ替えられる文字列
String to replace with
戻り値:
文字列の入れ替えが行われたテキスト
the text with any replacements processed
関連項目:
replace(String text, String repl, String with, int max)

replace

public static String replace(String text,
                             String repl,
                             String with)
対象の文字列内の全ての指定された文字列(repl)を指定された文字列(eith)に変換します。
Replace all occurances of a string within another string.

パラメータ:
text - 入れ替え対象の文字列を含むテキスト
text to search and replace in
repl - 入れ替え対象となる文字列
String to search for
with - 入れ替えられる文字列
String to replace with
戻り値:
文字列の入れ替えが行われたテキスト
the text with any replacements processed
関連項目:
replace(String text, String repl, String with, int max)

replace

public static String replace(String text,
                             String repl,
                             String with,
                             int max)
対象の文字列内の指定された文字列(repl)を先頭から max の回数分、指定された文字列(eith)に変換します。 null がこのメソッドに渡された場合には何も行いません。
Replace a string with another string inside a larger string, for the first max values of the search string. A null reference is passed to this method is a no-op.

パラメータ:
text - 入れ替え対象の文字列を含むテキスト
text to search and replace in
repl - 入れ替え対象となる文字列
String to search for
with - 入れ替えられる文字列
String to replace with
max - 入れ替えを行う最大回数。-1 の場合には制限なし -1 if no maximum
maximum number of values to replace, or -1 if no maximum
戻り値:
文字列の入れ替えが行われたテキスト
the text with any replacements processed
例外:
NullPointerException - 入れ替え対象となる文字列(repl) が null だった場合
if repl is null

overlayString

public static String overlayString(String text,
                                   String overlay,
                                   int start,
                                   int end)
文字列内の指定されたインデックスの場所を指定された文字列で上書きします。
Overlay a part of a string with another string.

パラメータ:
text - 上書きを行う対象となる文字列
String to do overlaying in
overlay - 上書きされる文字列
String to overlay
start - 上書きを行う開始位置
int to start overlaying at
end - 上書きを行う終了位置
int to stop overlaying before
戻り値:
文字列のうわがきが行われたテキスト
String with overlayed text
例外:
NullPointerException - テキストまたは上書きする文字列が null だった場合
if text or overlay is null

center

public static String center(String str,
                            int size)
指定された文字列が中心に配置された、指定された長さの文字列を返します。 空白が文字列を埋める際に使用されます。 これは center(str, size, " ") と同等です。
Center a string in a larger string of size n. Uses spaces as the value to buffer the string with. Equivalent to center(str, size, "")

パラメータ:
str - 中央に配置する文字列
str String to center
size - 新たに生成される文字列の長さ
size int size of new String
戻り値:
センタリングされた文字列
String containing centered String
例外:
NullPointerException - str が null だった場合
if str is null

center

public static String center(String str,
                            int size,
                            String delim)
指定された文字列が中心に配置された、指定された長さの文字列を返します。 指定された文字列が文字列を埋める際に使用されます。
Center a string in a larger string of size n. Uses a supplied String as the value to buffer the string with..

パラメータ:
str - 中央に配置する文字列
str String to center
size - 新たに生成される文字列の長さ
size int size of new String
delim - 新たな文字列の(左右を)埋めるために使用される文字列
String to buffer the new String with
戻り値:
センタリングされた文字列
String containing centered String
例外:
NullPointerException - str または delim が null だった場合
if str or delim is null
ArithmeticException - delim が空の文字列だった場合
if delim is the empty string

chomp

public static String chomp(String str)
(文字列の)最後の改行と、その後ろに続く全ての文字列を削除します。
Remove the last newline, and everything after it from a String.

パラメータ:
str - 改行以降を削除する対象となる文字列
String to chomp the newline from
戻り値:
改行以降が削除された文字列
String without chomped newline
例外:
NullPointerException - str が null だった場合
if str is null

chomp

public static String chomp(String str,
                           String sep)
最後に見つかった指定された文字列とその後ろに続く全ての文字列を削除し返します。
Remove the last value of a supplied String, and everything after it from a String.

パラメータ:
str - 末尾を削除する対象となる文字列
String to chomp from
sep - 削除する文字列
String to chomp
戻り値:
末尾が削除された文字列
String without chomped ending
例外:
NullPointerException - str または sep が null だった場合
if str or sep is null

chompLast

public static String chompLast(String str)
文字列の末尾が改行だった場合のみ、改行を削除します。
Remove a newline if and only if it is at the end of the supplied string.

パラメータ:
str - 末尾を削除する対象となる文字列
String to chomp from
戻り値:
末尾が削除された文字列
String without chomped ending
例外:
NullPointerException - str が null だった場合
if str is null

chompLast

public static String chompLast(String str,
                               String sep)
文字列の末尾が指定された文字列だった場合にのみ、末尾のこの文字列を削除します。
Remove a value if and only if the string ends with that value.

パラメータ:
str - 末尾を削除する対象となる文字列
String to chomp from
sep - 削除する文字列
String to chomp
戻り値:
末尾が削除された文字列
String without chomped ending
例外:
NullPointerException - str または sep が null だった場合
if str or sep is null

getChomp

public static String getChomp(String str,
                              String sep)
最後に見つかった指定された文字列の前の部分を全て削除し返します。
Remove everything and return the last value of a supplied String, and everything after it from a String.

パラメータ:
str - 末尾を取得する対象となる文字列
String to chomp from
sep - 末尾を取得する際に検索対象となる文字列
String to chomp
戻り値:
末尾の文字列
String chomped
例外:
NullPointerException - str または sep が null だった場合
if str or sep is null

prechomp

public static String prechomp(String str,
                              String sep)
最初に見つかった指定された文字列までを削除し、その後ろに続く文字列を返します。
Remove the first value of a supplied String, and everything before it from a String.

パラメータ:
str - 先頭をを削除する対象となる文字列
String to chomp from
sep - 先頭をを削除する際に検索対象となる文字列
String to chomp
戻り値:
先頭をを削除された文字列
String without chomped beginning
例外:
NullPointerException - str または sep が null だった場合
if str or sep is null

getPrechomp

public static String getPrechomp(String str,
                                 String sep)
最初に見つかった指定された文字列より後ろを全て削除し返します。
Remove and return everything before the first value of a supplied String from another String.

パラメータ:
str - 先頭を取得する対象となる文字列
String to chomp from
sep - 先頭を取得する際に検索対象となる文字列
String to chomp
戻り値:
先頭の文字列
String prechomped
例外:
NullPointerException - str または sep が null だった場合
if str or sep is null

chop

public static String chop(String str)
文字列の最後の1文字を削除し返します。 If the String 文字列の最後が \r\n の場合には、この両方を削除します。
Remove the last character from a String. If the String ends in \r\n, then remove both of them.

パラメータ:
str - 末尾を削除する対象となる文字列
String to chop last character from
戻り値:
末尾が削除された文字列
String without last character
例外:
NullPointerException - str が null だった場合
if str is null

chopNewline

public static String chopNewline(String str)
文字列の最後が \n たった場合にこれを削除します。 その前が \r だった場合にはこれも削除します。
Remove \n from end of a String if it's there. If a \r precedes it, then remove that too.

パラメータ:
str - 末尾の改行を削除する対象となる文字列
String to chop a newline from
戻り値:
末尾の改行が削除された文字列
String without newline
例外:
NullPointerException - str が null だった場合
if str is null

escape

public static String escape(String str)
文字列の中の全ての値をエスケープします。 例えばタブは '\\' と 't' の文字になります。
Escapes any values it finds into their String form. So a tab becomes the characters '\\' and 't'.

パラメータ:
str - エスケープの対象となる文字列
String to escape values in
戻り値:
エスケープされた文字列
String with escaped values
例外:
NullPointerException - if str is null

repeat

public static String repeat(String str,
                            int repeat)
指定された文字列を指定された回数繰り返し作成された文字列を返します。
Repeat a string n times to form a new string.

パラメータ:
str - 繰り返す文字列
String to repeat
repeat - 繰り返す回数
int number of times to repeat
戻り値:
繰り返された文字列
String with repeated string
例外:
NegativeArraySizeException - repeat が 0 よりも小さかった場合
if repeat < 0
NullPointerException - str が null だった場合
if str is null

rightPad

public static String rightPad(String str,
                              int size)
指定された長さになるまで文字列の右側(末尾)をスペースで埋めます。
Right pad a String with spaces. Pad to a size of n.

パラメータ:
str - 埋め込む対象となる文字列
String to repeat
size - 埋め込んだ後の文字列の長さ
int number of times to repeat
戻り値:
右側を埋められた文字列
right padded String
例外:
NullPointerException - str が null だった場合
if str is null

rightPad

public static String rightPad(String str,
                              int size,
                              String delim)
指定された長さになるまで文字列の右側(末尾)を指定された文字列で埋めます。
Right pad a String with a specified string. Pad to a size of n.

パラメータ:
str - 埋め込む対象となる文字列
String to pad out
size - 埋め込んだ後の文字列の長さ
int size to pad to
delim - 埋め込まれる文字列
String to pad with
戻り値:
右側を埋められた文字列
right padded String
例外:
NullPointerException - str または delim が null だった場合
if str or delim is null
ArithmeticException - delim が殻の文字列だった場合
if delim is the empty string

leftPad

public static String leftPad(String str,
                             int size)
指定された長さになるまで文字列の左側(先頭)をスペースで埋めます。
Left pad a String with spaces. Pad to a size of n.

パラメータ:
str - 埋め込む対象となる文字列
String to pad out
size - 埋め込んだ後の文字列の長さ
int size to pad to
戻り値:
左側を埋められた文字列
left padded String
例外:
NullPointerException - str が null だった場合
if str or delim is null

leftPad

public static String leftPad(String str,
                             int size,
                             String delim)
指定された長さになるまで文字列の左側(先頭)を指定された文字列で埋めます。
Left pad a String with a specified string. Pad to a size of n.

パラメータ:
str - 埋め込む対象となる文字列
String to pad out
size - 埋め込んだ後の文字列の長さ
int size to pad to
delim - 埋め込まれる文字列
String to pad with
戻り値:
左側を埋められた文字列
left padded String
例外:
NullPointerException - str または delim が null だった場合
if str or delim is null
ArithmeticException - delim が殻の文字列だった場合
if delim is the empty string

strip

public static String strip(String str)
文字列の前後から空白を削除します。
Remove whitespace from the front and back of a String.

パラメータ:
str - 空白を削除する対象となる文字列
the string to remove whitespace from
戻り値:
空白の削除された文字列
the stripped string

strip

public static String strip(String str,
                           String delim)
文字列の前後から指定された文字列を削除します。 空白を削除したい場合には strip(String) メソッドを使用してください。
Remove a specified String from the front and back of a String. If Whitespace is wanted to be removed, used the strip(String) method.

パラメータ:
str - 指定された文字列を削除する対象となる文字列
the string to remove a string from
delim - 前後から削除する文字列
the string to remove at start and end
戻り値:
指定された文字列の削除された文字列
the stripped string

stripAll

public static String[] stripAll(String[] strs)
配列の中の全ての文字列の前後から空白を削除します。
Strip whitespace from the front and back of every string in the array.

パラメータ:
strs - 空白を削除する対象となる文字列の配列
the strings to remove whitespace from
戻り値:
the 空白の削除された文字列の配列
the stripped strings

stripAll

public static String[] stripAll(String[] strs,
                                String delimiter)
配列の中の全ての文字列の前後から指定された文字列を削除します。
Strip the specified delimiter from the front and back of every String in the array.

パラメータ:
strs - 指定された文字列を削除する対象となる文字列の配列
the strings to remove a string from
delimiter - 前後から削除する文字列
the string to remove at start and end
戻り値:
指定された文字列の削除された文字列の配列
the stripped strings

stripEnd

public static String stripEnd(String str,
                              String strip)
文字列の最後から指定された文字列を削除します。 削除する文字列が null だった場合、空白が削除されます。
Strip any of a supplied string from the end of a String.. If the strip string is null, whitespace is stripped.

パラメータ:
str - 指定された文字を削除する対象となる文字列
the string to remove characters from
strip - 削除する文字列
the string to remove
戻り値:
指定された文字列の削除された文字列
the stripped string

stripStart

public static String stripStart(String str,
                                String strip)
文字列の最初から指定された文字列を削除します。 削除する文字列が null だった場合、空白が削除されます。
Strip any of a supplied string from the start of a String. If the strip string is null, whitespace is stripped.

パラメータ:
str - 指定された文字を削除する対象となる文字列
the string to remove characters from
strip - 削除する文字列
the string to remove
戻り値:
指定された文字列の削除された文字列
the stripped string

upperCase

public static String upperCase(String str)
文字列内の小文字を大文字に変換します。 null が指定された場合には null を返します。
Convert a String to upper case, null string returns null.

パラメータ:
str - 小文字を大文字に変換する対象となる文字列
the string to uppercase
戻り値:
小文字が大文字に変換された文字列
the upper cased string

lowerCase

public static String lowerCase(String str)
文字列内の大文字を小文字に変換します。 null が指定された場合には null を返します。
Convert a String to lower case, null string returns null.

パラメータ: