Commons-io-iocase
提供:Dev Guides
Apache Commons IO-IOCase
IOの大文字と小文字の区別の列挙。 オペレーティングシステムごとに、ファイル名の大文字と小文字の区別に関するルールが異なります。 たとえば、Windowsではファイル名の大文字と小文字が区別されませんが、Unixでは大文字と小文字が区別されます。 IOCaseはその違いをキャプチャし、ファイル名の比較の実行方法を制御する列挙を提供します。 また、列挙を使用して比較を実行するメソッドも提供します。
列挙宣言
以下は org.apache.commons.io.IOCase 列挙型の宣言です-
public enum IOCase
extends Enum<IOCase> implements Serializable
IOCase列挙の例
IOTester.java
import java.io.IOException;
import org.apache.commons.io.IOCase;
public class IOTester {
public static void main(String[] args) {
try {
usingIOCase();
} catch(IOException e) {
System.out.println(e.getMessage());
}
}
public static void usingIOCase() throws IOException {
String text = "Welcome to finddevguides. Simply Easy Learning.";
String text1 = "WELCOME TO finddevguides. SIMPLY EASY LEARNING.";
System.out.println("Ends with Learning (case sensitive): " +
IOCase.SENSITIVE.checkEndsWith(text1, "Learning."));
System.out.println("Ends with Learning (case insensitive): " +
IOCase.INSENSITIVE.checkEndsWith(text1, "Learning."));
System.out.println("Equality Check (case sensitive): " +
IOCase.SENSITIVE.checkEquals(text, text1));
System.out.println("Equality Check (case insensitive): " +
IOCase.INSENSITIVE.checkEquals(text, text1));
}
}
出力
次の結果が出力されます。
Ends with Learning (case sensitive): false
Ends with Learning (case insensitive): true
Equality Check (case sensitive): false
Equality Check (case insensitive): true