Есть поток вывода:
OutputStream outFile= new FileOutputStream("C:\\new.txt")
Можно как-нибудь проверить, закрыт этот поток или нет(т.е. вызван метод outFile.close() или нет)?
import java.io.File; import java.io.FileDescriptor; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class MyOutputStream extends FileOutputStream { private boolean isClosed = false; public MyOutputStream(File file, boolean append) throws FileNotFoundException { super(file, append); } public MyOutputStream(File file) throws FileNotFoundException { super(file); } public MyOutputStream(FileDescriptor fdObj) { super(fdObj); } public MyOutputStream(String name, boolean append) throws FileNotFoundException { super(name, append); } public MyOutputStream(String name) throws FileNotFoundException { super(name); } @Override public void close() throws IOException { isClosed = true; super.close(); } public synchronized boolean isClosed(){ return this.isClosed; } }