List of usage examples for java.io PrintWriter print
public void print(Object obj)
From source file:InputOutputDemo.java
public static void main(String[] a) throws Exception { PrintWriter pwr = new PrintWriter(new FileWriter("java2s.txt")); pwr.print(4711); pwr.print(' '); pwr.print("Java Source and Support at www.java2s.com"); pwr.close();/* w ww.j a v a 2s .c o m*/ StreamTokenizer stok = new StreamTokenizer(new FileReader("java2s.txt")); int tok = stok.nextToken(); while (tok != StreamTokenizer.TT_EOF) { System.out.println(stok.sval); tok = stok.nextToken(); } }
From source file:Main.java
public static void main(String args[]) throws Exception { SocketFactory factory = SSLSocketFactory.getDefault(); Socket socket = factory.createSocket("127.0.0.1", 8080); OutputStream outputStream = socket.getOutputStream(); PrintWriter out = new PrintWriter(outputStream); out.print("GET / HTTP/1.0\r\n\r\n"); out.flush();//from w ww .j av a2 s. com InputStream inputStream = socket.getInputStream(); InputStreamReader inputStreamReader = new InputStreamReader(inputStream); BufferedReader in = new BufferedReader(inputStreamReader); String line; while ((line = in.readLine()) != null) { System.out.println(line); } out.close(); in.close(); socket.close(); }
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); // flush the writer pw.flush();/*from w w w. j a va 2 s . co m*/ }
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); // print another long pw.print(987654321L);//ww w . j a va 2 s .c o m // 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/*w w w .java 2 s . c o 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) { float f = 1234.56f; PrintWriter pw = new PrintWriter(System.out); // print float pw.print(f); // change the line pw.println();//w w w. j a v a 2 s .c o m // print another float pw.print(1.23f); // flush the writer pw.flush(); }
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); // change line pw.println();//from w w w .j a va 2s . com // print another char pw.print('b'); // flush the writer pw.flush(); }
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); // change the line pw.println();/* w ww. j av a 2 s. co m*/ // print another double pw.print(987.654); // 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.print(s); // change the line twice pw.println();//from w w w. j ava 2 s .c om pw.println(); // print another string pw.print("Two lines."); // flush the writer pw.flush(); }
From source file:Main.java
public static void main(String[] args) { String s = "tutorial from java2s.com."; try {/* w w w .jav a 2s . c o m*/ PrintWriter pw = new PrintWriter(System.out); // print string pw.print(s); // change the line pw.println(); // print another string pw.print("This is an example."); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }