List of usage examples for java.io PrintWriter flush
public void flush()
From source file:Main.java
public static void main(String[] args) { long l = 1234567890L; PrintWriter pw = new PrintWriter(System.out); // print long pw.println(l);//from www.j a v a2s . c o m pw.println(987654321L); // flush the writer pw.flush(); }
From source file:Main.java
public static void main(String[] args) { double d = 123.456; PrintWriter pw = new PrintWriter(System.out); // print doubles pw.println(d);/*w w w .ja v a2 s . c o m*/ pw.println(987.765); // flush the writer pw.flush(); }
From source file:Main.java
public static void main(String[] args) { char[] c1 = { 'a', 'b', 'c', 'd', 'e' }; char[] c2 = { 'f', 'g', 'h', 'i', 'j' }; PrintWriter pw = new PrintWriter(System.out); // print char array pw.println(c1);//w w w .j ava 2s. co m pw.println(c2); // flush the writer pw.flush(); }
From source file:Main.java
public static void main(String[] args) { CharSequence sq1 = "Hello"; CharSequence sq2 = " World"; PrintWriter pw = new PrintWriter(System.out); // append the sequence pw.append(sq1);/*from ww w . jav a2 s . c o m*/ pw.append(sq2); // flush the writer pw.flush(); }
From source file:Main.java
public static void main(String[] args) { String s = "tutorial from java2s.com"; try {//from www . j a v a 2 s . com // create a new stream at specified file PrintWriter pw = new PrintWriter(System.out); // write the string in the file pw.write(s); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { int i = 70;/*from w w w . j a v a 2 s . c om*/ PrintWriter pw = new PrintWriter(System.out); // write integer as ASCII characters pw.write(i); pw.write(76); // flush the writer pw.flush(); }
From source file:Main.java
public static void main(String[] args) { CharSequence sq1 = "Hello"; CharSequence sq2 = " World"; PrintWriter pw = new PrintWriter(System.out); // append the sequence pw.append(sq1, 1, 3);//from ww w. ja v a 2 s.co m pw.append(sq2, 1, 4); // flush the writer pw.flush(); }
From source file:Main.java
public static void main(String[] args) { String s = "tutorial from java2s.com "; try {//from w w w .j a va 2 s. co m PrintWriter pw = new PrintWriter(System.out); // append the sequence pw.append(s); // flush the writer pw.flush(); // print another string pw.println("This is an example"); // flush the writer again pw.flush(); // close the writer pw.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { String s = "Hello"; try {/* w ww . j a v a 2s. c om*/ PrintWriter pw = new PrintWriter(System.out); // write strings pw.write(s); pw.write(" World"); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { boolean bool = false; try {//ww w.j a v a2 s . com PrintWriter pw = new PrintWriter(System.out); // print boolean pw.println(bool); pw.println(true); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }