List of usage examples for java.io PrintWriter println
public void println(Object x)
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); pw.println(987654321L);// ww w.java2 s .com // flush the writer pw.flush(); }
From source file:Main.java
public static void main(String[] args) { float f = 123.456f; PrintWriter pw = new PrintWriter(System.out); // print float pw.println(f); pw.println(987.765f);// w w w .j a v a2s . c o m // 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); pw.println("World"); // flush the writer pw.flush();/*from w w w. j av a2s . c o m*/ }
From source file:Main.java
public static void main(String[] args) { char c = 'a'; PrintWriter pw = new PrintWriter(System.out); // print string pw.println(c); pw.println('b'); // flush the writer pw.flush();/*from w ww. j a v a2 s .c o m*/ }
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); pw.println(987.765);/*from w w w. j a v a 2s . c o m*/ // 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); pw.println(c2);/*from w w w . j av a 2s. c om*/ // flush the writer pw.flush(); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { KeyGenerator kg = KeyGenerator.getInstance("DES"); kg.init(new SecureRandom()); SecretKey key = kg.generateKey(); SecretKeyFactory skf = SecretKeyFactory.getInstance("DES"); Class spec = Class.forName("javax.crypto.spec.DESKeySpec"); DESKeySpec ks = (DESKeySpec) skf.getKeySpec(key, spec); ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("keyfile")); oos.writeObject(ks.getKey());/*from w ww . j a v a 2s .c om*/ Cipher c = Cipher.getInstance("DES/CFB8/NoPadding"); c.init(Cipher.ENCRYPT_MODE, key); CipherOutputStream cos = new CipherOutputStream(new FileOutputStream("ciphertext"), c); PrintWriter pw = new PrintWriter(new OutputStreamWriter(cos)); pw.println("Stand and unfold yourself"); pw.close(); oos.writeObject(c.getIV()); oos.close(); }
From source file:Main.java
public static void main(String[] args) { boolean bool = false; try {/*from ww w .j a v a 2 s . c o m*/ PrintWriter pw = new PrintWriter(System.out); // print boolean pw.println(bool); pw.println(true); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
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); pw.println('A'); pw.println(500);/* ww w .j av a2s .c o m*/ 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) { Object obj1 = "Object"; Object obj2 = 2;//from w ww. jav a 2 s . c om Date date = new Date(); try { PrintWriter pw = new PrintWriter(System.out); // print object pw.println(obj1); // print another object pw.println(obj2); // print a date (it is an object) pw.print(date); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }