Java Tutorial/File/PrintStream — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 08:19, 1 июня 2010
Create print stream for error logger
<source lang="java">
import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; public class Main {
public static void main(String[] argv) throws Exception { try { } catch (Exception e) { e.printStackTrace(getErrorLoggerPrintStream()); } } public static PrintStream getErrorLoggerPrintStream() { try { PrintStream s = new PrintStream(new FileOutputStream(new File("c:\\log.txt"), true)); return s; } catch (FileNotFoundException e) { e.printStackTrace(); } return null; }
}</source>