List of usage examples for java.io PrintWriter flush
public void flush()
From source file:Main.java
public static void main(String[] args) { String s = "tutorial from java2s.com"; try {/*www . j a v a2 s. c o m*/ PrintWriter pw = new PrintWriter(System.out); // format text with default locale // %s indicates a string will be placed there, which is s pw.format("This is a %s program", s); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {/*ww w . ja va 2s .com*/ PrintWriter pw = new PrintWriter(System.out); // append chars pw.append('H'); pw.append('e'); pw.append('l'); pw.append('l'); pw.append('o'); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {//ww w .j a v a 2 s. c om PrintWriter pw = new PrintWriter("c:/text.txt"); // append chars pw.append('H'); pw.append('e'); pw.append('l'); pw.append('l'); pw.append('o'); // flush the writer pw.flush(); pw.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { Object obj1 = "Object"; Object obj2 = 2;/*from ww w . ja va 2 s . c o m*/ Date date = new Date(); try { PrintWriter pw = new PrintWriter(System.out); // print object pw.print(obj1); // print another object pw.print(obj2); // print a date (it is an object) pw.print(date); pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {//www .j av a 2 s . co m PrintWriter pw = new PrintWriter(System.out, true); // append chars pw.append('H'); pw.append('e'); pw.append('l'); pw.append('l'); pw.append('o'); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { String s = "tutorial from java2s.com"; try {/*www . j av a2 s .c o m*/ PrintWriter pw = new PrintWriter(System.out); // printf text with specified locale. // %s indicates a string will be placed there, which is s pw.printf(Locale.UK, "This is a %s program", s); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { String s = "tutorial from java2s.com"; try {/*from w w w .j ava2 s . c om*/ PrintWriter pw = new PrintWriter(System.out); // format text with specified locale. // %s indicates a string will be placed there, which is s pw.format(Locale.UK, "This is a %s program", s); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {//from w ww .ja v a2 s .c om PrintWriter pw = new PrintWriter("c:/text.txt", "ACSII"); // append chars pw.append('H'); pw.append('e'); pw.append('l'); pw.append('l'); pw.append('o'); // flush the writer pw.flush(); pw.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {// www .j a v a 2 s .c o m PrintWriter pw = new PrintWriter(new File("c:/text.txt")); // append chars pw.append('H'); pw.append('e'); pw.append('l'); pw.append('l'); pw.append('o'); // flush the writer pw.flush(); pw.close(); } catch (Exception ex) { ex.printStackTrace(); } }
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.print(s);//from w w w . j a v a2s. c o m // change the line twice pw.println(); pw.println(); // print another string pw.print("Two lines."); // flush the writer pw.flush(); }