ashok3sep
asked on
Java I/O problem
this is my program that i had written.
outstream = tcpipSocket.getOutputStrea
instream = tcpipSocket.getInputStream
//Identify Command Sequence.
int protocol_version = 513;
int check_sum = 543;
String protocol_name = "PRS";
byte[] identify = {10,20,(byte)protocol_vers
BufferedOutputStream bufferoutput1 = new BufferedOutputStream(outst
bufferoutput1.write(identi
bufferoutput1.flush();
length = instream.available();
BufferedInputStream bufferinput1 = new BufferedInputStream(instre
for (int i=1; i<=length; i++)
{
byte response = (byte)bufferinput1.read();
System.out.print(response)
}
I dont want to have a byte array to add all the codes in side the byte array.
Instead it should be possible for me to add strings, integers, and bytes to the output stream.
how could i do it.
please help me out to reach the solution
With regards,
Ashok.G
use DataOutputStream.
Hi D4Ly,
You can use the BufferedWriter instead
nesnemis
You can use the BufferedWriter instead
nesnemis
Use ObjectInputStream and ObjectOutputStream to send the objects you want. You will need to pass to the ObjectInput/OutputStream constructors the input/output stream of the socket. For more info: http://java.sun.com/developer/technicalArticles/ALT/sockets/
easy:
if u have String for example u can simply:
String strVal = "hello i will become a byte array now";
byte[] byteValue = strVal.getBytes();
for int u can do this
byte[] byteValue = String.valueOf(12).getByte s();
if u have String for example u can simply:
String strVal = "hello i will become a byte array now";
byte[] byteValue = strVal.getBytes();
for int u can do this
byte[] byteValue = String.valueOf(12).getByte
Go to the section where it says "Transporting Objects over Sockets"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.