title: Retaining the name of the transferred file
body: <p>I am using normal Java Socket Programming to successfully transfer a known file. This is my code snippet:</p>
  
  <pre><code>Socket sock = new Socket("192.168.1.3", 6789);
  byte[] mybytearray = new byte[9999];
  InputStream is = sock.getInputStream();
  FileOutputStream fos = new FileOutputStream("filename.txt");
  BufferedOutputStream bos = new BufferedOutputStream(fos);
  int bytesRead = is.read(mybytearray, 0, mybytearray.length);
  bos.write(mybytearray, 0, bytesRead);
  bos.close();
  sock.close();
  </code></pre>
  
  <p>However in this code I have to explicitly name the receiving file as <code>filename.txt</code>, I want to retain the name of the file that is getting transferred. One way to do is to explicitly transfer the name of the file and then transfer the file (I think it is correct) OR is there any other way to do that?</p>