There is such a method which read a file and do something:
public void readFileAndDoSomething(File file) {
InputStream inputStream = new FileInputStream(file);
// a lot of complex code which reads the inputStream
// and we don't know if the inputStream is closed or not
}
Now I want to test the method to make sure if any input stream that uses the file is closed or not finally.
My test code:
public void test() {
File testFile = new File("my_test_file");
readFileAndDoSomething(testFile);
// is it possible to just check the file to make sure
// if it is still used by some unclosed input streams?
}
Please see my comment in the test
method, is it possible?