title: checking if a directory exists on a remote machine and copying the file on it
body: <p>I have a shared folder F on a remote machine M. Now I want to run a program on my local machine which does following.</p>
  
  <pre><code>Check if subfoder  S exists with \\remoteMachine\F
     if S exists then copy my file tstfile.txt within S
     else if S does not exist then 
        create S at \\remoteMachine\F and 
        copy tstfile.txt within S.
  </code></pre>
  
  <p>Currently I am using the following to copy file, but I can't figure out the folder copy logic</p>
  
  <pre><code> InputStream in = new FileInputStream(new File("C:\\testData\\aks.txt"));
   OutputStream out = new FileOutputStream(new File("\\remotemachine\\tst.txt"));
  
   //Transfer bytes from in to out
   byte[] buf = new byte[1024];
   int len;
   while ((len = in.read(buf)) &gt; 0) {
       out.write(buf, 0, len);
   }
   in.close();
   out.close();
   System.out.append("done with copying");
  </code></pre>