public ReadOnlyExclusiveCodecFileBuffer(File dataFile, File indexFile, FileHeaderStrategy fileHeaderStrategy) throws IOException { this.indexStrategy = new DefaultIndexStrategy(); if(!dataFile.canRead()) { throw new IllegalArgumentException("'"+dataFile.getAbsolutePath()+"' is not readable."); } if(!indexFile.canRead()) { throw new IllegalArgumentException("'"+indexFile.getAbsolutePath()+"' is not readable."); } lock.lock(); try { FileHeader header = fileHeaderStrategy.readFileHeader(dataFile); if(header == null) { throw new IllegalArgumentException("Could not read file header from file '" + dataFile.getAbsolutePath() + "'. File isn't compatible."); } setFileHeader(header); randomAccessIndexFile = new RandomAccessFile(indexFile, "r"); randomAccessDataFile = new RandomAccessFile(dataFile, "r"); } finally { lock.unlock(); } }
public ReadOnlyExclusiveCodecFileBuffer(File dataFile, File indexFile, FileHeaderStrategy fileHeaderStrategy) throws IOException { this.indexStrategy = new DefaultIndexStrategy(); if(!dataFile.canRead()) { throw new IllegalArgumentException("'"+dataFile.getAbsolutePath()+"' is not readable."); } if(!indexFile.canRead()) { throw new IllegalArgumentException("'"+indexFile.getAbsolutePath()+"' is not readable."); } lock.lock(); try { FileHeader header = fileHeaderStrategy.readFileHeader(dataFile); if(header == null) { throw new IllegalArgumentException("Could not read file header from file '" + dataFile.getAbsolutePath() + "'. File isn't compatible."); } setFileHeader(header); randomAccessIndexFile = new RandomAccessFile(indexFile, "r"); randomAccessDataFile = new RandomAccessFile(dataFile, "r"); } finally { lock.unlock(); } }