/** * Get number of bytes that are available to be read. * <p> * Note that the number of bytes available plus * the number of bytes free may not add up to the * capacity of this buffer, as the buffer may reserve some * space for other purposes. * * @return the size in bytes of this buffer * * @since ostermillerutils 1.00.00 */ public int getAvailable(){ synchronized (this){ return available(); } }
/** * If we have passed the markSize reset the * mark so that the space can be used. * * @since ostermillerutils 1.00.00 */ private void ensureMark(){ if (marked() > markSize){ markPosition = readPosition; markSize = 0; } }
/** * Get the number of bytes this buffer has free for * writing. * <p> * Note that the number of bytes available plus * the number of bytes free may not add up to the * capacity of this buffer, as the buffer may reserve some * space for other purposes. * * @return the available space in bytes of this buffer * * @since ostermillerutils 1.00.00 */ public int getSpaceLeft(){ synchronized (this){ return spaceLeft(); } }
throw new RarException(RarExceptionType.notImplementedYet); final CircularByteBuffer cbb = new CircularByteBuffer(CircularByteBuffer.INFINITE_SIZE); return cbb.getInputStream();
/** * double the size of the buffer * * @since ostermillerutils 1.00.00 */ private void resize(){ byte[] newBuffer = new byte[buffer.length * 2]; int marked = marked(); int available = available(); if (markPosition <= writePosition){ // any space between the mark and // the first write needs to be saved. // In this case it is all in one piece. int length = writePosition - markPosition; System.arraycopy(buffer, markPosition, newBuffer, 0, length); } else { int length1 = buffer.length - markPosition; System.arraycopy(buffer, markPosition, newBuffer, 0, length1); int length2 = writePosition; System.arraycopy(buffer, 0, newBuffer, length1, length2); } buffer = newBuffer; markPosition = 0; readPosition = marked; writePosition = marked + available; }
public void run(){ try { archive.extractFile(header, cbb.getOutputStream()); } catch (RarException e) { if (e.getType() != RarExceptionType.crcError) e.printStackTrace(); } finally { try { cbb.getOutputStream().close(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } }
final CircularByteBuffer cbb = new CircularByteBuffer(CircularByteBuffer.INFINITE_SIZE); new Thread( new Runnable(){ return cbb.getInputStream();
public void run(){ MuArchiveExtractCallback extractCallbackSpec = new MuArchiveExtractCallback(cbb.getOutputStream(), entry.getPath()); extractCallbackSpec.Init(sevenZipFile); try { sevenZipFile.Extract(arrays, 1, IInArchive.NExtract_NAskMode_kExtract , extractCallbackSpec); } catch (Exception e) { e.printStackTrace(); // return; } } }