How Do I Create An Output Stream


  • 2 Feb, 2012

    On the client side, you can create an output stream to send information to the server socket using the class PrintStream or DataOutputStream of java.io:PrintStream output;try {output = new PrintStream(MyClient.getOutputStream());}catch (IOException e) {System.out.println(e);}The class PrintStream has methods for displaying textual representation of Java primitive data types. Its Write and println methods are important here. Also, you may want to use the DataOutputStream:DataOutputStream output;try {output = new DataOutputStream(MyClient.getOutputStream());}catch (IOException e) {System.out.println(e);}The class DataOutputStream allows you to write Java primitive data types; many of its methods write a single Java primitive type to the output stream. The method writeBytes is a useful one.On the server side, you can use the class PrintStream to send information to the client.PrintStream output;try {output = new PrintStream(serviceSocket.getOutputStream());}catch (IOException e) {System.out.println(e);}Note: You can use the class DataOutputStream as mentioned above.

    Comments Received:
    Please give your suggestions and feedback:

2009-2016 downloadmela.com. All rights reserved.