java.nio.channels.FileChannel.tryLock() method.
java.nio.channels.FileChannel channel = new RandomAccessFile(file,
fileMode).getChannel();
java.ino.channels.FileLock lock = channel.tryLock();
> org.objectweb.howl.log.LogConfigurationException: java.io.IOException:
> Value too large for defined data type
> at org.objectweb.howl.log.LogFile.open(LogFile.java:179)
Java docs for tryLock() say this is equivalent to tryLock(0L,
Long.MAX_LONG,false); which is a request to lock the entire file.
This code works on various Windows, Linux, and MacOS systems. I do not have
access to a debian system, so I wonder if someone could kindly throw
together a small java app to test this for me on debian?
The customer is using JVM 1.5, so I suspect it is either Sun or Jrockit, but
the customer has not told me which.
Thanks
Michael Giroux
import java.io.*;
import java.nio.channels.*;
public class test {
public static void main(String[] args) {
try {
java.nio.channels.FileChannel channel = new RandomAccessFile("test.txt", "rw").getChannel();
java.nio.channels.FileLock lock = channel.tryLock();
System.out.println("Success");
} catch (IOException e) {
e.printStackTrace();
}
}
}