files sending over socket
Here is my server-code:
for (int i=0; i<countGamesToDownload; i++)
{
out.write(gamesToDownload.get(i) +".zip\n");
out.flush();
filename=System.getProperty("user.dir")+"\\"+ gamesToDownload.get(i)+".zip";
System.out.println("Filename: " + filename);
bin =new BufferedInputStream(new FileInputStream(new File(filename)));
int len = 0;
while ((len = bin.read(buffer)) > 0){
bout.write(buffer, 0, len);
System.out.println("#");
}
bin.close();
bout.flush();
}
That's my client-code:
for (GameInfo gi : gamesToDownloadVec)
{
filename="C:\\Temp\\" + in.readLine();
System.out.println ("Filename: " + filename);
bout =new BufferedOutputStream(new FileOutputStream(new File(filename)));
int bytesRead = 0;
while((bytesRead =bin.read(buffer))>0)
{
bout.write(buffer, 0, bytesRead);
System.out.println("#");
}
bout.flush();
bout.close();
//new Unzip(new File(filename));
}
If I only send one game everything is fine...
but if i send more than i get as second filename: C:\Temp\null
If i am debugging the server, i get on theserver-side:
file:\C:\Dokumente und Einstellungen\Edith\Eigene Dateien\java\eclipse-projekte\GameDownloadServer\GameList.xml is well-formed.
Anzahl neuer Spiele: 4
Filename: C:\Dokumente und Einstellungen\Edith\Eigene Dateien\java\eclipse-projekte\GameDownloadServer\Game1.zip
#
Filename: C:\Dokumente und Einstellungen\Edith\Eigene Dateien\java\eclipse-projekte\GameDownloadServer\Game2.zip
#
client-side:
Filename: C:\Temp\Game1.zip
#
#
#
Filename: C:\Temp\null
Only one # is ok, because the file is only ablout 1800 kb and my buffer-size is 1024*50...
I don't know where the problem is. it would be very great if anyone can help me...
Greatings
schaefli

