Java I/O help !!!!!!!!!!!!
Posted on 2004-11-16
I have a class xxxxxx to connect to a server through TCPIP protocol. after making a connection i am sending a sequence of commands to the server ( say for example 10 commands) now i have pasted a sample of only one command IDENTIFY.
I write to the dataoutputstream as a bytearray identify.
after that i receive the reply from the server in the form of bytes.
so i have a value in the reply of the server in the form of string starting from 10th byte to the 44th byte
i need to print in the form of a string itself
but i have it in numbers printed.
how should i do it in order to have in the desired format.
i also want to know whether it is possible for me to use the same instream and outstream for all the commands that i send in a row to the server.
if that is possible do i have any methods to flush the instream and outstream after every command i send.
public class xxxxxx
private Socket tcpipSocket;
private tcpipParameters tcpipparameters;
public void OpenConnection() throws ConnectException,UnknownHostException
tcpipSocket = new Socket (tcpipparameters.getIpAddress(),tcpipparameters.getPortNumber());
outstream = tcpipSocket.getOutputStream();
instream = tcpipSocket.getInputStream();
dos = new DataOutputStream(outstream);
dis = new DataInputStream(instream);
// The IDENTIFY Command
int length1 = instream.available();
for (int i=1; i<=length1; i++)
byte reply = (byte)dis.read();