Get your own Java server
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    new File("filename.txt").createNewFile();
    FileInputStream input = new FileInputStream("filename.txt");
    input.close();
    try {
      input.read();
    } catch (IOException e) {
      System.out.println("Error: the stream is closed.");
    }
  }
}

              
Error: the stream is closed.