private byte getOneByte() throws IOException { oneByte.rewind(); if (file.read(oneByte) < 1) { throw new EndOfFileException(getFileName()); } return oneByte.get(0); }
private byte getOneByte() throws IOException { oneByte.rewind(); if (file.read(oneByte) < 1) { throw new EndOfFileException(getFileName()); } return oneByte.get(0); }
private synchronized String readNextChunk(int capacity) throws IOException { if (capacity == 0) { throw new EndOfFileException("Zero chunk size, possibly end of file reached."); } ByteBuffer buf = ByteBuffer.allocateDirect(capacity); byte[] dst = new byte[capacity]; int cnt = file.read(buf); //log.debug("Read " + cnt); if (cnt != capacity) { throw new IOException("Expected chunk size (" + capacity + ") differs from read bytes count (" + cnt + ")"); } buf.flip(); buf.get(dst); if (log.isDebugEnabled()) { log.debug("Chunk : " + new String(dst)); } if (isHexEncode()) { return JOrphanUtils.baToHexString(dst); } else { return new String(dst, binaryCharset); } }
private synchronized String readNextChunk(int capacity) throws IOException { if (capacity == 0) { throw new EndOfFileException("Zero chunk size, possibly end of file reached."); } ByteBuffer buf = ByteBuffer.allocateDirect(capacity); byte[] dst = new byte[capacity]; int cnt = file.read(buf); //log.debug("Read " + cnt); if (cnt != capacity) { throw new IOException("Expected chunk size (" + capacity + ") differs from read bytes count (" + cnt + ")"); } buf.flip(); buf.get(dst); if (log.isDebugEnabled()) { log.debug("Chunk : " + new String(dst)); } if (isHexEncode()) { return JOrphanUtils.baToHexString(dst); } else { return new String(dst, binaryCharset); } }