title: JSch, lock file while session is open
body: <p>Is there any way to lock file, which i am reading with JSch sftp channel, to prevent other applications to modificate it while session is open?</p>
  
  <p>The problem i have: while i am reading/writing file, some other application changes the file and its causes errors. </p>
  
  <p>Currently i am reading file in such way:</p>
  
  <pre><code>ChannelSftp sftp = (ChannelSftp) session.openChannel("sftp");
  
  InputStream stream = sftp.get("/some/file");
  try {
      BufferedReader br = new BufferedReader(new InputStreamReader(stream));
      // read from br
  } finally {
      stream.close();
  }
  </code></pre>