1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
private Message receiveMessage(Socket currentSocket) {
// get the input stream
FileInputStream fileBuffer;
Message msg = null;
try {
fileBuffer = (FileInputStream)currentSocket.getInputStream();
//save the file
File fichier = new File("tmpFile");
fichier.createNewFile();
//prepare the output stream to save the file
FileOutputStream fileDestination = new FileOutputStream(fichier);
byte buff[] = new byte[512*1024];
int nbLecture;
System.out.println("line 55");
while( (nbLecture = fileBuffer.read(buff)) != -1 ) {
System.out.println(nbLecture);
fileDestination.write(buff, 0, nbLecture);
} // c'est ici qu'il se plante, il ne dépasse jamais cette frontiere
System.out.println("line 59");
//fileBuffer.close();
ObjectInputStream in = new ObjectInputStream(new FileInputStream("tmpFile"));
msg = (Message)in.readObject();
System.out.println("line 64");
in.close();
fichier.delete();
System.out.println("line 67");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return msg;
} |
Partager