source:
doc/theses/rob_schluntz_MMath/examples/intro/res2.java@
427a577
| Last change on this file since 427a577 was 67982887, checked in by , 8 years ago | |
|---|---|
|
|
| File size: 688 bytes | |
| Rev | Line | |
|---|---|---|
| [9c14ae9] | 1 | import java.io.IOException; |
| 2 | ||
| 3 | public class res2 implements ires { | |
| 4 | public void write(String filename, String msg) throws Exception { | |
| 5 | FileOutputStream out = new FileOutputStream(filename); // may throw FileNotFoundException | |
| 6 | try { | |
| 7 | FileOutputStream log = new FileOutputStream("log.txt"); // or SecurityException | |
| 8 | try { | |
| 9 | out.write(msg.getBytes()); // may throw an IOException | |
| 10 | log.write(msg.getBytes()); // may throw an IOException | |
| 11 | } finally { | |
| 12 | log.close(); // may throw an IOException | |
| 13 | } | |
| 14 | } finally { | |
| 15 | out.close(); // may throw an IOException | |
| 16 | } | |
| 17 | } | |
| 18 | ||
| 19 | public static void main(String[] args) { | |
| 20 | res.dotest(new res2()); | |
| 21 | } | |
| 22 | } |
Note:
See TracBrowser
for help on using the repository browser.