title: Basics - reading/writing remote files using Java
body: <p>I started with requirement of reading and writing files in from/in a directory on a remote Ubuntu machine.</p>
  
  <p>First, I wrote a Java program that could read,write files from a shared folder on a remote Windows machine i.e on a LAN. Here, something like this works on my(local) Windows machine :</p>
  
  <pre><code>File inputFile = new File(
                  "\\172.17.89.76\EBook PDF");/*ignore the syntax errors, the loc is just for the idea*/
  </code></pre>
  
  <p>Now when I consider a remote Ubuntu machine, obviously I cannot do something like this as the machine is not on the LAN(<em>I'm not sure if that can be done even if it is on the LAN</em>!). Hence, I tried following approaches :</p>
  
  <ol>
  <li>Using Jsch, establishing the trust between two machines(local - remote Linux , remote Linux - remote Linux) and file writing using sftp.(done)</li>
  <li>Running sockets on the two machines - one sender, one receiver(both Java)(done)</li>
  <li>Attempting to achieve I/O alike the code snippet for Windows (LAN) machines(not achieved)</li>
  </ol>
  
  <p>While doing all these, I had many queries, read many posts etc. and I felt that I'm missing something on the fundamentals :</p>
  
  <ul>
  <li>Some sort of trust-building(between two machines) utility will be required to achieve IO. But finally, I want to write a code like the snippet given, irrespective of the machines, network etc.</li>
  <li>The Jsch solution and the others suggested(usage of http, ftp etc. over URL) finally are using some services that are running on the remote machine. In other words, it is NOT THAT Java IO is being used to access the remote file system - this doesn't appeal to me as I'm relying on services rather than using good-old I/O.</li>
  <li>Samba, SSHFS too popped onto the scene, only to add to my confusion. But I don't see them as the solutions to my objective !</li>
  </ul>
  
  <p>To reiterate, <strong>I want to write a code using Java I/O(either plain or nio, both are fine) which simply can read, write remote files without using services over protocols like ftp, http etc. or socket sender-receiver model</strong>. Is my expectation valid?</p>
  
  <ul>
  <li>If not, why and what is the best I can do to read/write remote files
  using Java?</li>
  <li>If yes, how to achieve the same !</li>
  </ul>
  
  <p>P.S : Please comment in case I need to elaborate to pose my question accurately !</p>