Skip to content

Instantly share code, notes, and snippets.

@ejknapp
Created September 20, 2011 21:07
Show Gist options
  • Save ejknapp/1230344 to your computer and use it in GitHub Desktop.
Save ejknapp/1230344 to your computer and use it in GitHub Desktop.
package java112.labs1;
import java.io.*;
/**
* @author Eric Knapp
* class DemoOutput
*
*/
public class DemoOutput {
public void run() {
PrintWriter out = null;
try {
out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt", true)));
writeSomeStuff(out);
} catch (IOException ioException) {
ioException.printStackTrace();
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (out != null){
out.close();
}
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
private void writeSomeStuff(PrintWriter out) {
out.println("Hi.");
}
public static void main(String[] args) {
DemoOutput lab = new DemoOutput();
lab.run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment