unable 2 read bytes array of images

I have made a client application which will

receive an image from server

the mobile app (clent) is reveiving bytes array in emulator

but unable 2 receive it in real application...

message = new byte[2073];//string 2 read pic;

for(i=0;i<2073;i++)

{

//read pic array byte by byte

x=is.read();//(is is an input stream)

message= (byte)x;

}

// also tried this

//is.read(message)

works fine in emulator but not in real appication in sony erricson k310i

[546 byte] By [maaz01a] at [2007-11-27 8:22:52]
# 1
plz help as soon as possibel
maaz01a at 2007-7-12 20:11:40 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
There really is no way this is ever going to work.Youre casting an int to a byte and trying to assign it to a byte array.You might be best off reading a book about the basic java stuff..
deepspacea at 2007-7-12 20:11:40 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3

sorry actually code was.....

for reading byte by byte...............

message = new byte[2073]; //string 2 read pic;

for(i=0;i<2073;i++)

{

//read pic array byte by byte

x=is.read(); //(is is an input stream)

message= (byte)x;

}

//for reading whole array message

// also tried this

is.read(message)

and i think there shall be no problem in converting an int into byte

maaz01a at 2007-7-12 20:11:40 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4

sorry actually code was.....

for reading byte by byte...............

message = new byte[2073]; //string 2 read pic;

for(i=0;i<2073;i++)

{

//read pic array byte by byte

x=is.read(); //(is is an input stream)

message= (byte)x;

}

//for reading whole array message

// also tried this

is.read(message)

and i think there shall be no problem in converting an int into byte

maaz01a at 2007-7-12 20:11:40 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5

sorry actually code was.....

for reading byte by byte...............

message = new byte[2073]; //string 2 read pic;

for(a=0;a<2073;a++)

{

//read pic array byte by byte

x=is.read(); //(is is an input stream)

message[a]= (byte)x; //problem in last post i[] //converting it into italic

}

//for reading whole array message

// also tried this

is.read(message)

and i think there shall be no problem in converting an int into byte

maaz01a at 2007-7-12 20:11:40 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 6
are you sure the image size is 2073bytes?i guess you used DataInputStream to read data from a connection.DataInputStream.read(byte[]) does not read the whole image. It only reads what is available in the connection buffer. you should read in a while loop
RiekeyLeea at 2007-7-12 20:11:40 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 7
> and i think there shall be no problem in converting> an int into byteThink again! A byte in java is signed, an therefore conversion will not work very well. This will do the trick though:byte bval = (byte) (intval &0xff);
deepspacea at 2007-7-12 20:11:40 > top of Java-index,Java Mobility Forums,Java ME Technologies...