'file lock'에 해당되는 글 1건

  1. 파일에 락 걸기.. 2008/06/13

파일에 락 걸기..

from Java 2008/06/13 17:52

try {
        File file = new File("filename");
        FileChannel channel = new RandomAccessFile(file, "rw").getChannel();

        FileLock lock = channel.lock();
        try {
            lock = channel.tryLock();
        } catch (OverlappingFileLockException e) {
            // File is already locked in this thread or virtual machine
        }

        lock.release();

        channel.close();
        
}catch(Exception e){
}

Tag // , , ,