I have a static initializer where I am creating a new File object. When I pass in the name to it FindBugs reports a warning due to the hard-coded absolute path. How can I suppress this warning?
private static final String fileName = "/tmp/m123.txt";
static {
if (new File(fileName).exists()) {
....
}
}
You could move this hard-coded filename to a properties file, or command line argument etc.
See this page for a tutorial on property files http://www.mkyong.com/java/java-properties-file-examples/
In you want to ignore this warning though as per the page findbugs.sourceforge.net/manual/running.html#commandLineOptions you can use -exclude filterFile.xml