public long length() {
   try {
     return image.length();
   } catch (IOException e) {
     return -1L;
   }
 }
 public int write(byte[] data, int offset, int length) throws IOException {
   image.write(data, offset, length);
   return length;
 }
 public void seek(long offset) throws IOException {
   image.seek(offset);
 }
 public void close() throws IOException {
   image.close();
 }
 public int read(byte[] data, int offset, int length) throws IOException {
   return image.read(data, offset, length);
 }
Beispiel #6
0
 public static FileLock lock_file(String path) throws IOException, FileNotFoundException {
   RandomAccessFile file = new RandomAccessFile(path, "rw");
   FileChannel fileChannel = file.getChannel();
   return fileChannel.tryLock();
 }