List of usage examples for java.io PrintStream PrintStream
public PrintStream(File file) throws FileNotFoundException
From source file:Main.java
public static void main(String[] args) { Object x = 50;/*from w w w. ja va 2 s . c o m*/ Object s = "from java2s.com"; PrintStream ps = new PrintStream(System.out); // print objects ps.print(x); ps.print(s); // flush the stream ps.flush(); }
From source file:Main.java
public static void main(String[] args) throws Exception { byte c = 70;// w w w .j a va2 s.co m PrintStream ps = new PrintStream("c:/text.txt"); // write byte c which is character F in ASCII ps.write(c); // flush the stream ps.flush(); }
From source file:Main.java
public static void main(String[] args) throws Exception { byte c = 70;//from w w w . j a va 2s . c om PrintStream ps = new PrintStream(new File("c:/text.txt")); // write byte c which is character F in ASCII ps.write(c); // flush the stream ps.flush(); }
From source file:Main.java
public static void main(String[] args) throws Exception { File file = new File("C:\\a.txt"); PrintStream ps = new PrintStream(file); System.setOut(ps);//from w ww. ja v a 2s . c om System.out.println("To File"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.dat")))); }
From source file:Main.java
public static void main(String[] args) { String s = "from java2s.com."; // create a new PrintStream PrintStream ps = new PrintStream(System.out); // print a string ps.println(s);/*w ww . j av a2 s.c o m*/ // check for errors and print ps.print(ps.checkError()); ps.flush(); ps.close(); }
From source file:Main.java
public static void main(String[] args) { char[] s = { 'a', 'b', 'c' }; char[] c = { 'H', 'e', 'l', 'l', 'o' }; PrintStream ps = new PrintStream(System.out); // print char array ps.print(s);/*from w ww . j ava 2 s . com*/ ps.print(c); // flush the stream ps.flush(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { System.setOut(new LogStream(System.out, new PrintStream(new FileOutputStream("out.log")))); System.setErr(new LogStream(System.err, new PrintStream(new FileOutputStream("err.log")))); System.out.println("output"); System.err.println("error"); }
From source file:Main.java
public static void main(String[] args) throws Exception { FileOutputStream f = new FileOutputStream("file.txt"); System.setErr(new PrintStream(f)); System.err.println("This will get redirected to file from java2s.com"); }
From source file:Main.java
public static void main(String[] args) throws Exception { FileOutputStream f = new FileOutputStream("file.txt"); System.setOut(new PrintStream(f)); System.out.println("This is from java2s.com"); }