Cześć. Mam problem z przesyłaniem pliku przez sockety (server -> client) Mój kod wygląda tak:
SERVER:
public void sendFile(File file) {
BufferedOutputStreambufferedOutputStream = new BufferedOutputStream(socket.getOutputStream());
int count;
FileInputStream in;
try {
in = new FileInputStream(file);
byte[] mybytearray = new byte[(int) file.length()];
while ((count = in.read(mybytearray)) > 0) {
bufferedOutputStream.write(mybytearray, 0, count);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
CLIENT:
public void downloadFile() {
byte[] aByte = new byte[8192];
int count;
FileOutputStream in;
try {
in = new FileOutputStream("C://fis.txt");
while ((count = bufferedInputStream.read(aByte)) > 0) {
in.write(aByte, 0, count);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Funkcja **downloadFile **nie może sobie poradzić z odczytaniem. Co robię źle ?