Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. File file = ...;
  2. FileInputStream fis = new FileInputStream(file); // or FileOutputStream fos = new FileOutputStream(file);
  3. FileLock lock = fis.getChannel().lock(); // or FileLock lock = fos.getChannel().lock();
  4.  
  5. // do whatever you want with the file
  6.  
  7. lock.release();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement