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
)? ;-)
File names: Traditionally, Unix-like operating systems treat file names case-sensitively while Microsoft Windows is case-insensitive but, for most file systems, case-preserving.
Standard behavior: Windows file system treats file and directory names as case-insensitive.
Type the following command to enable NTFS to treat the folder's content as case sensitive and press Enter: fsutil.exe file SetCaseSensitiveInfo C:\folder\path enable In the command, remember to include the path to the folder you want to enable case sensitivity.
Text or typed input that is sensitive to capitalization of letters. For example, "Computer" and "computer" are two different words because the "C" is uppercase in the first example and lowercase in the second example.
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)
boolean isFileSystemCaseSensitive = !new File( "a" ).equals( new File( "A" ) );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With