Skip to content

Instantly share code, notes, and snippets.

@arttuladhar
Created July 31, 2015 03:51
Show Gist options
  • Save arttuladhar/228f3911b39b0cf20166 to your computer and use it in GitHub Desktop.
Save arttuladhar/228f3911b39b0cf20166 to your computer and use it in GitHub Desktop.
PrintWriter
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.Writer;
public class PlayingWithStrings {
/**
* @param args
*/
public static void main(String[] args) {
PrintWriter syslog = null;
PrintWriter screen = new PrintWriter(System.out,true);
try {
syslog = new PrintWriter("syslog.txt");
} catch (FileNotFoundException e) {
e.printStackTrace();
return;
}
syslog.println("Starting Program");
screen.println("Starting the Program");
syslog.println("Logid");
screen.println("Processing Logic");
syslog.println("Closing Log");
screen.println("Closing Log File");
syslog.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment