javafilesystemscase-sensitivesystem-properties

How do I detect whether the file system is case-sensitive?


I have a List<String> of file names from a folder and a certain file name as String. I want to detect whether the file name is in the list, but need to respect the underlying file system's property of whether it is case-sensitive.

Is there any easy way to do this (other than the "hack" of checking System.getProperty("os.name", "").toLowerCase().indexOf("windows")!=-1)? ;-)


Solution

  • Don't use Strings to represent your files; use java.io.File:

    http://java.sun.com/javase/6/docs/api/java/io/File.html#equals(java.lang.Object)