/** Write bytes array (with offset length) to the file */ public void write() throws IOException { if (offset > 0) { da.append(bytes, 0, offset); } offset = 0; }
public void close() throws IOException { opened = false; da.close(); }
public int getFileLength() throws IOException { return da.getFileLength(); }
public void seek(int filePointer) throws IOException { da.seek(filePointer); }
private void ensureOpen(boolean requestWrite) throws IOException { if (!opened) { da.open(requestWrite); opened = true; } }
public int getFilePointer() throws IOException { return (int)da.getFilePointer(); }
/** Read some part of the file into the begining of bytes array * and reset offset to zero. */ public void read(int len) throws IOException { checkBytesSize(len); da.read(bytes, 0, len); offset = 0; }
/** Reset the size of the file and set current offset to zero. */ public void resetFile() throws IOException { open(true); offset = 0; da.resetFile(); close(); }
public void open(boolean requestWrite) throws IOException { if (openedForWrite == requestWrite) { ensureOpen(requestWrite); da.seek(getFileLength()); return; // already opened with correct type } else { // opened with different type close(); } // open the file ensureOpen(requestWrite); da.seek(getFileLength()); openedForWrite = requestWrite; offset = 0; }