title: Wrong transfer of a file over Java socket
body: <p>I am trying to transfer an XML file from a desktop server to an Android client but I get on the Android device just 1024 bytes of the entire file. My code is:</p>
  
  <hr>
  
  <h2>Sending the file from the desktop server to the Android client:</h2>
  
  <pre><code>byte[] mybytearray = new byte[(int) filePianificazione.length()];
  
  BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(filePianificazione));
  
  bufferedInputStream.read(mybytearray, 0, mybytearray.length);
  
  bufferedInputStream.close();
  
  out.write(mybytearray, 0, mybytearray.length);
  
  out.flush();
  </code></pre>
  
  <hr>
  
  <h2>Receiving of the file from the Android client to the server:</h2>
  
  <pre><code>byte[] mybytearray = new byte[1024];
  
  FileOutputStream fos = new FileOutputStream(file.getAbsolutePath());
  
  BufferedOutputStream bos = new BufferedOutputStream(fos);
  
  int bytesRead = in.read(mybytearray, 0, mybytearray.length);
  
  bos.write(mybytearray, 0, bytesRead);
  
  bos.close();
  </code></pre>