I have following piece of code:
/**
* Performs the filename extension check (command-line argument validity).
* @param valid True, if the check should be performed.
* @param filename File name to test.
* @return False, if the test was done and the filename does not end with
* ".xml". Value of valid otherwise.
*/
private boolean checkFileNameExtension(final boolean valid,
final String filename) {
boolean result = valid;
if (valid
&& !filename.toLowerCase(Locale.ENGLISH).endsWith(".xml")) {
this.logger.error("File doesn't have XML extension.");
result = false;
}
return result;
}
FindBugs complains about the toLowerCase
call:
[WARNING] FindBugs: L I Dm: Use of non-localized String.toUpperCase() or
String.toLowerCase() in [...]checkFileNameExtension(boolean, String)
How can I correctly fix that warning (the proper way), if I can be sure that all file names will always have names with Latin letters only?
Adding Locale.ENGLISH (or Locale.ROOT) is the proper way to fix the error, so if FindBugs is still reporting that error after you add that, then you might have found a bug in FindBugs itself.
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