public final byte[] read(long offset, int bytes) throws IOException { byte[] out = new byte[bytes]; dataSource.seek(offset); dataSource.readFully(out); return out; }
public final byte[] read(long offset, int bytes) throws IOException { byte[] out = new byte[bytes]; dataSource.seek(offset); dataSource.readFully(out); return out; }
public ConcurrentBitInBuffered(RandomDataInput file, long startByteOffset, byte _bitOffset, int _bufLength) { super(); this.offset = startByteOffset; this.bitOffset= _bitOffset; this.parentFile = file; this.size = _bufLength; try{ synchronized (parentFile) { parentFile.seek(startByteOffset); inBuffer = new byte[size]; parentFile.readFully(inBuffer); } readByteOffset = 0; byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
public ConcurrentBitInBuffered(RandomDataInput file, long startByteOffset, byte _bitOffset, int _bufLength) { super(); this.offset = startByteOffset; this.bitOffset= _bitOffset; this.parentFile = file; this.size = _bufLength; try{ synchronized (parentFile) { parentFile.seek(startByteOffset); inBuffer = new byte[size]; parentFile.readFully(inBuffer); } readByteOffset = 0; byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
/** Move forward i bytes */ protected void incrByte(int i) { try{ //System.out.println("skypping"); offset += i; readByteOffset+=i; if( readByteOffset >= size ) // we go to the next block -- we skip only the begin of the block { parentFile.seek(offset); // we skip the first bytes of the next block //Arrays.fill(inBuffer, (byte)0); readByteOffset = 0; //logger.info("Reading 1024 bytes. pos="+parentFile.getFilePointer()); try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} } byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
/** Move forward i bytes */ protected void incrByte(int i) { try{ //System.out.println("skypping"); offset += i; readByteOffset+=i; if( readByteOffset >= size ) // we go to the next block -- we skip only the begin of the block { parentFile.seek(offset); // we skip the first bytes of the next block //Arrays.fill(inBuffer, (byte)0); readByteOffset = 0; //logger.info("Reading 1024 bytes. pos="+parentFile.getFilePointer()); try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} } byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
/** Move forward one byte */ protected void incrByte() { try{ readByteOffset++; offset++; if(readByteOffset == size) { readByteOffset=0; //Arrays.fill(inBuffer, (byte)0); parentFile.seek(offset); //logger.info("Reading 1024 bytes. pos="+parentFile.getFilePointer()); try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} } byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
@Override protected void incrByte() { try{ readByteOffset++; offset++; if(readByteOffset == size) { readByteOffset=0; synchronized (parentFile) { parentFile.seek(offset); try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} } } byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
@Override protected void incrByte(int i) { try{ //System.out.println("skypping"); offset += i; readByteOffset+=i; if( readByteOffset >= size ) // we go to the next block -- we skip only the begin of the block { synchronized (parentFile) { parentFile.seek(offset); // we skip the first bytes of the next block readByteOffset = 0; try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} } } byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
@Override public void skipBytes(long len) throws IOException { if (readByteOffset + len >= inBuffer.length) { offset += len; synchronized (parentFile) { parentFile.seek(offset); // we skip the first bytes of the next block readByteOffset = 0; try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} } byteRead = inBuffer[readByteOffset]; } else { offset += len; readByteOffset += len; bitOffset = 0; byteRead = inBuffer[readByteOffset]; } } }
/** Construct a new BitInBuffered on the specified file, starting at the given offset * and with the specified buffer length. * @param file File to seek on * @param startByteOffset Start byte offset * @param _bitOffset Start bit offset * @param _bufLength Number of bytes to buffer */ public BitInBuffered(RandomDataInput file, long startByteOffset, byte _bitOffset, int _bufLength) { this.offset = startByteOffset; this.bitOffset= _bitOffset; this.parentFile = file; this.size = _bufLength; try{ parentFile.seek(startByteOffset); inBuffer = new byte[size]; parentFile.readFully(inBuffer); readByteOffset = 0; byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
/** Move forward one byte */ protected void incrByte() { try{ readByteOffset++; offset++; if(readByteOffset == size) { readByteOffset=0; //Arrays.fill(inBuffer, (byte)0); parentFile.seek(offset); //logger.info("Reading 1024 bytes. pos="+parentFile.getFilePointer()); try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} } byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
@Override protected void incrByte() { try{ readByteOffset++; offset++; if(readByteOffset == size) { readByteOffset=0; synchronized (parentFile) { parentFile.seek(offset); try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} } } byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
@Override protected void incrByte(int i) { try{ //System.out.println("skypping"); offset += i; readByteOffset+=i; if( readByteOffset >= size ) // we go to the next block -- we skip only the begin of the block { synchronized (parentFile) { parentFile.seek(offset); // we skip the first bytes of the next block readByteOffset = 0; try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} } } byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
/** Construct a new BitInBuffered on the specified file, starting at the given offset * and with the specified buffer length. * @param file File to seek on * @param startByteOffset Start byte offset * @param _bitOffset Start bit offset * @param _bufLength Number of bytes to buffer */ public BitInBuffered(RandomDataInput file, long startByteOffset, byte _bitOffset, int _bufLength) { this.offset = startByteOffset; this.bitOffset= _bitOffset; this.parentFile = file; this.size = _bufLength; try{ parentFile.seek(startByteOffset); inBuffer = new byte[size]; parentFile.readFully(inBuffer); readByteOffset = 0; byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
/** {@inheritDoc} */ public void skipBytes(long len) throws IOException { //this version skipBytes() is compatible with len==0 //if (len == 0) //{ // return; //} if (readByteOffset + len >= inBuffer.length) { offset += len; parentFile.seek(offset); // we skip the first bytes of the next block readByteOffset = 0; try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} byteRead = inBuffer[readByteOffset]; } else { offset += len; readByteOffset += len; bitOffset = 0; byteRead = inBuffer[readByteOffset]; } }
@Override public void skipBytes(long len) throws IOException { if (readByteOffset + len >= inBuffer.length) { offset += len; synchronized (parentFile) { parentFile.seek(offset); // we skip the first bytes of the next block readByteOffset = 0; try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} } byteRead = inBuffer[readByteOffset]; } else { offset += len; readByteOffset += len; bitOffset = 0; byteRead = inBuffer[readByteOffset]; } } }
/** {@inheritDoc} */ public void skipBytes(long len) throws IOException { //this version skipBytes() is compatible with len==0 //if (len == 0) //{ // return; //} if (readByteOffset + len >= inBuffer.length) { offset += len; parentFile.seek(offset); // we skip the first bytes of the next block readByteOffset = 0; try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} byteRead = inBuffer[readByteOffset]; } else { offset += len; readByteOffset += len; bitOffset = 0; byteRead = inBuffer[readByteOffset]; } }