title: Unable to read from newly locked file
body: <p>So I try to locked the file to read it, but I got IOException, any idea why?</p>
  
  <pre><code>public static void main(String[] args){
      File file = new File("C:\\dev\\harry\\data.txt");
  
      FileReader fileReader = null;
      BufferedReader bufferedReader = null;
      FileChannel channel = null;
      FileLock lock = null;
      try{
          channel  = new RandomAccessFile(file, "rw").getChannel();
          lock = channel.lock();
          fileReader = new FileReader(file);
          bufferedReader = new BufferedReader(fileReader);
          String data;
          while((data = bufferedReader.readLine()) != null){
              System.out.println(data);
          }
      }catch(IOException e){
          e.printStackTrace();
      }finally{
          try {
              lock.release();
              channel.close();
              if(bufferedReader != null) bufferedReader.close();
              if(fileReader != null) fileReader.close();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>and I got this error <code>IOException: The process cannot access the file because another process has locked a portion of the file</code></p>