Having the following falsly detects that the stream may not be closed. This inputstream should be closed wherever this inputstream is created instead of in this class.
public class TempFileInputStream extends FileInputStream {
private final File tmpFile;
/**
* Constructor.
* @param file een tempfile die verwijderd kan worden bij het sluiten van de stream.
* @throws FileNotFoundException
*/
public TempFileInputStream(File file) throws FileNotFoundException {
super(file);
this.tmpFile = file;
}
@Override
public void close() throws IOException {
try {
super.close();
} finally {
tmpFile.delete();
}
}
}
Example added, see https://code.google.com/p/findbugs/source/detail?r=7984da58cdb0023172dbb6eb9564d5d8f0bd0cb6
Fixed, thank you.