Home | History | Annotate | Download | only in io
      1 package org.jf.dexlib2.writer.io;
      2 
      3 import org.jf.util.RandomAccessFileInputStream;
      4 import org.jf.util.RandomAccessFileOutputStream;
      5 
      6 import javax.annotation.Nonnull;
      7 import java.io.*;
      8 
      9 public class FileDataStore implements DexDataStore {
     10     private final RandomAccessFile raf;
     11 
     12     public FileDataStore(@Nonnull File file) throws FileNotFoundException, IOException {
     13         this.raf = new RandomAccessFile(file, "rw");
     14         this.raf.setLength(0);
     15     }
     16 
     17     @Nonnull @Override public OutputStream outputAt(int offset) {
     18         return new RandomAccessFileOutputStream(raf, offset);
     19     }
     20 
     21     @Nonnull @Override public InputStream readAt(int offset) {
     22         return new RandomAccessFileInputStream(raf, offset);
     23     }
     24 
     25     @Override public void close() throws IOException {
     26         raf.close();
     27     }
     28 }
     29