/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

package foam.blob;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class FileBlob
  extends InputStreamBlob
{
  protected File file_;

  public FileBlob(File file) throws FileNotFoundException {
    super(new FileInputStream(file), (int) file.length());
    file_ = file;
  }

  public File getFile() {
    return this.file_;
  }
}
@@ -141,121 +141,189 @@
 b;%0A%0A
-import java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.FileNotFoundException
+public class FileBlob extends AbstractBlob %7B%0A  public static final int BUFFER_SIZE = 4096;%0A%0A  private java.io.File file_;%0A  private java.io.RandomAccessFile raf_
 ;%0A%0A
+  
 public 
-class 
 FileBlob
 %0A  e
@@ -322,60 +322,140 @@
 Blob
-%0A  extends InputStreamBlob%0A%7B%0A  protected 
+(java.io.File file) throws java.io.IOException %7B%0A    file_ = file;%0A    raf_ = new java.io.RandomAccess
 File
- 
+(
 file
-_;
+.getPath(), %22r%22);%0A  %7D
 %0A%0A  
@@ -465,140 +465,518 @@
 lic 
-FileBlob(
+java.io.
 File 
-f
+getF
 ile
+(
 ) 
-throws FileNotFoundException %7B%0A    super(new FileInputStream(file), (int) file.length());%0A    file_ = file;%0A  %7D%0A
+%7B%0A    return this.file_;%0A  %7D%0A%0A  @Override%0A  public long read(java.io.OutputStream out, long offset, long length) %7B%0A    try %7B%0A      byte%5B%5D buffer = new byte%5BBUFFER_SIZE%5D;%0A      raf_.seek(offset);%0A      long read = 0;%0A      while ( read %3C length ) %7B%0A        int n = raf_.read(buffer, 0,%0A          Math.min((int)(length - read), BUFFER_SIZE));%0A        out.write(buffer, 0, n);%0A        read += n;%0A      %7D%0A      return read;%0A    %7D catch (Throwable t) %7B%0A      return -1;%0A    %7D%0A  %7D%0A%0A  @Override
 %0A  p
@@ -981,27 +981,27 @@
  public 
-File
+long
  get
-Fil
+Siz
 e() %7B%0A  
@@ -1013,21 +1013,33 @@
 urn 
-this.
 file_
+.getTotalSpace()
 ;%0A  %7D%0A%7D
+%0A

Make FileBlob able to read at any position