First of all, sorry of my english, because I am Spanish. I am developping a Client/Server application using sockets. I must transfer a .jpg file. This is the code I use in the server to receive the file:
byte[] datos = new byte[(int)longitud]; dis.skipBytes(1);// long i = 0; while (i<longitud) { datos[(int)i] = dis.readByte(); i++; } File foto = new File("./Mascarada/fotosServidor/" + codigoSubida + ".jpg"); FileOutputStream fos = new FileOutputStream(foto); fos.write(datos); fos.close();//
I think the problem is in this part of code, because I have tested that all the bytes are sent to the server. The server gets blocked always when it reads a byte with the integer value '-39'. It is very strange.
Do you know a better way of sending a file using sockets?