Currently I am using code like this
while (fileName.endsWith(".csv")) {
fileName = fileName.substring(0, fileName.lastIndexOf(FILE_SUFFIX_CSV));
if (fileName.trim().isEmpty()) {
throw new IllegalArgumentException();
}
}
The above code works fine when user specifies extension in small letters(.csv),But windows accepts extensions case sensitive so he can give like .CsV ,.CSV etc. how can I alter above code ?
Thanks in Advance
why don't you turn it to lowercase?
while (fileName.toLowerCase().endsWith(".csv")) {
fileName = fileName.substring(0, fileName.toLowerCase().lastIndexOf(FILE_SUFFIX_CSV));
if (fileName.trim().isEmpty()) {
throw new IllegalArgumentException();
}
}