Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)? ;-)

like image 413
Epaga Avatar asked Aug 17 '09 13:08

Epaga


People also ask

Which file systems are case sensitive?

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.

Is Windows 10 file system case sensitive?

Standard behavior: Windows file system treats file and directory names as case-insensitive.

How do I make Windows file system case sensitive?

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.

Which command is considered as case sensitive?

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.


2 Answers

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)

like image 119
Steve M Avatar answered Sep 28 '22 02:09

Steve M


boolean isFileSystemCaseSensitive = !new File( "a" ).equals( new File( "A" ) );
like image 23
Alexander Avatar answered Sep 28 '22 03:09

Alexander