How to pass integer values between sockets?

Hi all,

I figured out how to pass strings of text between sockets (like this...)

PrintWriter ClientOut = null; // to send messages to the server

BufferedReader ClientIn = null; // to receive messages from the server.

PrintWriter ServerOut = null; // to send messages to the client

BufferedReader ServerIn = null; // to receive messages from the client.

and then to write a string of text you do this...

ServerOut.write("here is some text");

ServerOut.flush();

and then you read it on the other side like this...

ServerIn.readLine();

My question today is how to write integers and read them. I know I could write them in a text format, but when I read them I want to do something like this...

int temp = 0;

temp = ServerIn.readInteger(); (or whatever)

could someone help me with this?

Thanks

[917 byte] By [philcollins] at [2007-9-26 2:02:01]
# 1
You could wrap a DataInputStream and a DataOutputStream around the sockets' streams. They let you read and write ints through the readInt and writeInt methods.
jsalonen at 2007-6-29 8:43:01 > top of Java-index,Archived Forums,Java Programming...