Java I/O

Creating Streams

//Read and write some text
Socket a_socket = new Socket(www.sc.edu, 80);
InputStreamReader isr = new InputStreamReader(a_socket.getInputStream());
BufferedReader in = new BufferedReader (isr);
PrinterWriter out = new PrinterWriter(a_socket.getOutputStream()); 

//Read and write some binary data
Socket socket_data = new Socket(www.sc.edu, 100);
DataInputStream in_data = new DataInputStream(Socket_data.getInputStream());
DataOutputStream out_data = new DataOutputStream(socket_data.getOutputStream());


José M. Vidal .

2 of 13