InterviewSolution
| 1. |
How Do I Create An Output Stream? |
|
Answer» 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; 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; 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; Note: You can use the class DataOutputStream as mentioned above. 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; 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; 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; Note: You can use the class DataOutputStream as mentioned above. |
|