List of usage examples for java.nio.channels FileLock isValid
public abstract boolean isValid();
From source file:org.pentaho.di.trans.steps.excelinput.PoiWorkBookIT.java
License:asdf
@Test public void testResourceFree() throws Exception { FileLock lock = null; RandomAccessFile randomAccessFile = null; try {//from w ww . ja va2 s .c om readData(sampleFile, null); File fileAfterRead = new File(sampleFile); randomAccessFile = new RandomAccessFile(fileAfterRead, "rw"); FileChannel fileChannel = randomAccessFile.getChannel(); lock = fileChannel.tryLock(); // check that we could lock file assertTrue(lock.isValid()); } finally { if (lock != null) { lock.release(); } if (randomAccessFile != null) { randomAccessFile.close(); } } }
From source file:org.pentaho.di.trans.steps.excelinput.PoiWorkBookTest.java
@Test public void testResourceFree() throws Exception { FileLock lock = null; RandomAccessFile randomAccessFile = null; try {/* w w w . j ava2s. c o m*/ readData(); File fileAfterRead = new File("testfiles/sample-file.xlsx"); randomAccessFile = new RandomAccessFile(fileAfterRead, "rw"); FileChannel fileChannel = randomAccessFile.getChannel(); lock = fileChannel.tryLock(); // check that we could lock file assertTrue(lock.isValid()); } finally { if (lock != null) { lock.release(); } if (randomAccessFile != null) { randomAccessFile.close(); } } }
From source file:org.pentaho.di.trans.steps.excelinput.StaxWorkBookIT.java
@Test public void testRead() throws Exception { FileLock lock = null; RandomAccessFile randomAccessFile = null; try {//from w w w .j a v a 2 s . c o m readData(sample); File fileAfterRead = new File(sample); randomAccessFile = new RandomAccessFile(fileAfterRead, "rw"); FileChannel fileChannel = randomAccessFile.getChannel(); lock = fileChannel.tryLock(); // check that we could lock file assertTrue(lock.isValid()); } finally { if (lock != null) { lock.release(); } if (randomAccessFile != null) { randomAccessFile.close(); } } }
From source file:org.pentaho.di.trans.steps.excelinput.StaxWorkBookTest.java
@Test public void testRead() throws Exception { FileLock lock = null; RandomAccessFile randomAccessFile = null; try {//from w w w .j a v a 2s .c o m readData(); File fileAfterRead = new File("testfiles/sample-file.xlsx"); randomAccessFile = new RandomAccessFile(fileAfterRead, "rw"); FileChannel fileChannel = randomAccessFile.getChannel(); lock = fileChannel.tryLock(); // check that we could lock file assertTrue(lock.isValid()); } finally { if (lock != null) { lock.release(); } if (randomAccessFile != null) { randomAccessFile.close(); } } }