Help: transfering files with obex
Helo, I'm writing an obex server and client, just to transfer files between two computers
Everything seems to go ok, the client connects to the server and starts transfering the file, and the server achieves the file name, size ... but when I go to see the file, the file exists but its length is 0 bytes. This is the code of the server:
java.io.InputStream is = op.openInputStream();
int size;
String name;
size = Integer.parseInt(((Long) op.getReceivedHeaders().getHeader(HeaderSet.LENGTH)).toString());
name = op.getReceivedHeaders().getHeader(HeaderSet.NAME).toString();
File f =new File(name);
FileOutputStream fos =new FileOutputStream(f);
byte b[] =newbyte[size];
int len;
while (is.available() > 0 && (len = is.read(b)) > 0){
fos.write(b, 0, len);
}
updateStatus("[server:] Wrote data to " + f.getAbsolutePath());
updateStatus("Got data bytes " + size +" name " + name +" type " + op.getType());
op.close();
is.close();
fos.close();
Can you help me? Thanks.

