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
)? ;-)
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" ) );
看起来你可以使用IOCase
。
Write a file named "HelloWorld"; attempt to read a file named "hELLOwORLD"?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.