send image from computer to mobile
i want to send image from computer to mobile using tcp socket
i tried the following code but it does not work
could any one help me
the code in the computer application (server)
InputStream input=new FileInputStream("dynamics.jpg");
byte[] buffer=new byte[1024];
int readData;
while((readData=input.read(buffer))!=-1){
output.write(buffer,0,readData);
the code in the mobile
int len = is.available(); //where is openInputStream();
byte [] imgByte = new byte[len];
ByteArrayOutputStream bStr = new ByteArrayOutputStream();
int ch = 0;
while ( (ch = is.read()) != -1 ) {
bStr.write(ch);
}
is.close();
imgByte = bStr.toByteArray();
bStr.close();
Image imgRes = Image.createImage(imgByte, 0, imgByte.length);
imageItem.setImage(imgRes);