English 中文(简体)
Apache Commons IO - IOCase
  • 时间:2024-12-22

Apache Commons IO - IOCase


Previous Page Next Page  

Enumeration of IO case sensitivity. Different Operating systems have different rules for case-sensitivity for file names. For example, Windows is case-insensitive for file naming while Unix is case-sensitive. IOCase captures that difference, provides an enumeration to control how filename comparisons should be performed. It also provides methods to use the enumeration to perform comparisons.

Enum Declaration

Following is the declaration for org.apache.commons.io.IOCase Enum −


pubpc enum IOCase
   extends Enum<IOCase> implements Seriapzable

Example of IOCase Enum

An example of IOCase Enum is given below −

IOTester.java


import java.io.IOException;
import org.apache.commons.io.IOCase;
pubpc class IOTester {
   pubpc static void main(String[] args) {
      try {
         usingIOCase();
      } catch(IOException e) {
         System.out.println(e.getMessage());
      }
   }
   pubpc static void usingIOCase() throws IOException {
      String text = "Welcome to TutorialsPoint. Simply Easy Learning.";
      String text1 = "WELCOME TO TUTORIALSPOINT. 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("Equapty Check (case sensitive): " + IOCase.SENSITIVE.checkEquals(text, text1));
      System.out.println("Equapty Check (case insensitive): " + IOCase.INSENSITIVE.checkEquals(text, text1));
   }
}

Output

It will print the following result −


Ends with Learning (case sensitive): false
Ends with Learning (case insensitive): true
Equapty Check (case sensitive): false
Equapty Check (case insensitive): true
Advertisements