import java.io.IOException;

public class res2 implements ires {
  public void write(String filename, String msg) throws Exception {
    FileOutputStream out = new FileOutputStream(filename); // may throw FileNotFoundException
    try {
      FileOutputStream log = new FileOutputStream("log.txt"); //  or SecurityException
      try {
        out.write(msg.getBytes()); // may throw an IOException
        log.write(msg.getBytes()); // may throw an IOException
      } finally {
        log.close(); // may throw an IOException
      }
    } finally {
      out.close(); // may throw an IOException
    }
  }

  public static void main(String[] args) {
    res.dotest(new res2());
  }
}
