List of usage examples for java.io PrintWriter PrintWriter
public PrintWriter(File file) throws FileNotFoundException
From source file:Main.java
public static void main(String[] args) { char c = 'a'; PrintWriter pw = new PrintWriter(System.out); // print chars pw.print(c);//from w w w.j a v a 2 s . c o m // change line pw.println(); // print another char pw.print('b'); // flush the writer pw.flush(); }
From source file:Main.java
public static void main(String[] args) { int i = 1234; PrintWriter pw = new PrintWriter(System.out); // print int// www .j a va 2 s.co m pw.print(i); // change the line pw.println(); // print another int pw.print(567); // flush the writer pw.flush(); }
From source file:Main.java
public static void main(String[] args) { char c = 'A'; Writer writer = new PrintWriter(System.out); try {//from w w w. j a v a 2s. c o m // append a char writer.append('c'); // append a new char writer.append(c); // flush the writer to see the result writer.flush(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { long i = 1234567890L; PrintWriter pw = new PrintWriter(System.out); // print long pw.print(i);/*from w w w . ja va 2s .c o m*/ // print another long pw.print(987654321L); // flush the writer pw.flush(); }
From source file:Main.java
public static void main(String[] args) { int c = 70;/* w w w . ja v a 2 s .c o m*/ Writer writer = new PrintWriter(System.out); try { // write an int that will be printed as ASCII writer.write(c); // flush the writer writer.flush(); // write another int that will be printed as ASCII writer.write(71); // flush the stream again writer.flush(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { float f = 1234.56f; PrintWriter pw = new PrintWriter(System.out); // print float pw.print(f);/*from w ww. ja v a 2s . c om*/ // change the line pw.println(); // print another float pw.print(1.23f); // flush the writer pw.flush(); }
From source file:Main.java
public static void main(String[] args) { String s = "from java2s.com"; PrintWriter pw = new PrintWriter(System.out); // print string pw.println(s);/* www.java 2s . c o m*/ pw.println("World"); // flush the writer pw.flush(); }
From source file:PrintWriterDemo.java
public static void main(String args[]) throws Exception { PrintWriter pw = new PrintWriter(System.out); // Experiment with some methods pw.println(true);/* w w w. java 2s .c om*/ pw.println('A'); pw.println(500); pw.println(40000L); pw.println(45.67f); pw.println(45.67); pw.println("Hello"); pw.println(new Integer("99")); // Close print writer pw.close(); }
From source file:Main.java
public static void main(String[] args) { double d = 1234.567; PrintWriter pw = new PrintWriter(System.out); // print double pw.print(d);//from w w w. j ava 2 s . c om // change the line pw.println(); // print another double pw.print(987.654); // flush the writer pw.flush(); }
From source file:Main.java
public static void main(String[] args) { char[] c = { 'a', 'b', 'c', 'd' }; PrintWriter pw = new PrintWriter(System.out); // print char array pw.print(c);/*from w w w .jav a 2 s.c o m*/ // flush the writer pw.flush(); }