Codota Logo
PoolingByteArrayOutputStream
Code IndexAdd Codota to your IDE (free)

How to use
PoolingByteArrayOutputStream
in
com.android.volley.toolbox

Best Java code snippets using com.android.volley.toolbox.PoolingByteArrayOutputStream (Showing top 20 results out of 315)

  • Common ways to obtain PoolingByteArrayOutputStream
private void myMethod () {
PoolingByteArrayOutputStream p =
  • Codota IconByteArrayPool pool;HttpEntity entity;new PoolingByteArrayOutputStream(pool, (int)entity.getContentLength())
  • Codota IconByteArrayPool pool;new PoolingByteArrayOutputStream(pool)
  • Smart code suggestions by Codota
}
origin: mcxiaoke/android-volley

/** Reads the contents of HttpEntity into a byte[]. */
private byte[] entityToBytes(HttpEntity entity) throws IOException, ServerError {
  PoolingByteArrayOutputStream bytes =
      new PoolingByteArrayOutputStream(mPool, (int) entity.getContentLength());
  byte[] buffer = null;
  try {
    InputStream in = entity.getContent();
    if (in == null) {
      throw new ServerError();
    }
    buffer = mPool.getBuf(1024);
    int count;
    while ((count = in.read(buffer)) != -1) {
      bytes.write(buffer, 0, count);
    }
    return bytes.toByteArray();
  } finally {
    try {
      // Close the InputStream and release the resources by "consuming the content".
      entity.consumeContent();
    } catch (IOException e) {
      // This can happen if there was an exception above that left the entity in
      // an invalid state.
      VolleyLog.v("Error occured when calling consumingContent");
    }
    mPool.returnBuf(buffer);
    bytes.close();
  }
}
origin: mcxiaoke/android-volley

@Override
public synchronized void write(byte[] buffer, int offset, int len) {
  expand(len);
  super.write(buffer, offset, len);
}
origin: mcxiaoke/android-volley

  private void writeBytesIndividually(ByteArrayPool pool) {
    byte[] data = new byte[16384];
    for (int i = 0; i < data.length; i++) {
      data[i] = (byte) (i & 0xff);
    }
    PoolingByteArrayOutputStream os = new PoolingByteArrayOutputStream(pool);
    for (int i = 0; i < data.length; i++) {
      os.write(data[i]);
    }

    assertTrue(Arrays.equals(data, os.toByteArray()));
  }
}
origin: mcxiaoke/android-volley

private void writeOneBuffer(ByteArrayPool pool) throws IOException {
  byte[] data = new byte[16384];
  for (int i = 0; i < data.length; i++) {
    data[i] = (byte) (i & 0xff);
  }
  PoolingByteArrayOutputStream os = new PoolingByteArrayOutputStream(pool);
  os.write(data);
  assertTrue(Arrays.equals(data, os.toByteArray()));
}
origin: chentao0707/SimplifyReader

/** Reads the contents of HttpEntity into a byte[]. */
private byte[] entityToBytes(HttpEntity entity) throws IOException, ServerError {
  PoolingByteArrayOutputStream bytes =
      new PoolingByteArrayOutputStream(mPool, (int) entity.getContentLength());
  byte[] buffer = null;
  try {
    InputStream in = entity.getContent();
    if (in == null) {
      throw new ServerError();
    }
    buffer = mPool.getBuf(1024);
    int count;
    while ((count = in.read(buffer)) != -1) {
      bytes.write(buffer, 0, count);
    }
    return bytes.toByteArray();
  } finally {
    try {
      // Close the InputStream and release the resources by "consuming the content".
      entity.consumeContent();
    } catch (IOException e) {
      // This can happen if there was an exception above that left the entity in
      // an invalid state.
      VolleyLog.v("Error occured when calling consumingContent");
    }
    mPool.returnBuf(buffer);
    bytes.close();
  }
}
origin: jiangqqlmj/FastDev4Android

private void writeOneBuffer(ByteArrayPool pool) throws IOException {
  byte[] data = new byte[16384];
  for (int i = 0; i < data.length; i++) {
    data[i] = (byte) (i & 0xff);
  }
  PoolingByteArrayOutputStream os = new PoolingByteArrayOutputStream(pool);
  os.write(data);
  assertTrue(Arrays.equals(data, os.toByteArray()));
}
origin: chentao0707/SimplifyReader

  @Override
  public synchronized void write(int oneByte) {
    expand(1);
    super.write(oneByte);
  }
}
origin: jiangqqlmj/FastDev4Android

/** Reads the contents of HttpEntity into a byte[]. */
private byte[] entityToBytes(HttpEntity entity) throws IOException, ServerError {
  PoolingByteArrayOutputStream bytes =
      new PoolingByteArrayOutputStream(mPool, (int) entity.getContentLength());
  byte[] buffer = null;
  try {
    InputStream in = entity.getContent();
    if (in == null) {
      throw new ServerError();
    }
    buffer = mPool.getBuf(1024);
    int count;
    while ((count = in.read(buffer)) != -1) {
      bytes.write(buffer, 0, count);
    }
    return bytes.toByteArray();
  } finally {
    try {
      // Close the InputStream and release the resources by "consuming the content".
      entity.consumeContent();
    } catch (IOException e) {
      // This can happen if there was an exception above that left the entity in
      // an invalid state.
      VolleyLog.v("Error occured when calling consumingContent");
    }
    mPool.returnBuf(buffer);
    bytes.close();
  }
}
origin: jiangqqlmj/FastDev4Android

  private void writeBytesIndividually(ByteArrayPool pool) {
    byte[] data = new byte[16384];
    for (int i = 0; i < data.length; i++) {
      data[i] = (byte) (i & 0xff);
    }
    PoolingByteArrayOutputStream os = new PoolingByteArrayOutputStream(pool);
    for (int i = 0; i < data.length; i++) {
      os.write(data[i]);
    }

    assertTrue(Arrays.equals(data, os.toByteArray()));
  }
}
origin: mcxiaoke/android-volley

  @Override
  public synchronized void write(int oneByte) {
    expand(1);
    super.write(oneByte);
  }
}
origin: xuningjack/AndroidNet

/** Reads the contents of HttpEntity into a byte[]. */
private byte[] entityToBytes(HttpEntity entity) throws IOException, ServerError {
  PoolingByteArrayOutputStream bytes =
      new PoolingByteArrayOutputStream(mPool, (int) entity.getContentLength());
  byte[] buffer = null;
  try {
    InputStream in = entity.getContent();
    if (in == null) {
      throw new ServerError();
    }
    buffer = mPool.getBuf(1024);
    int count;
    while ((count = in.read(buffer)) != -1) {
      bytes.write(buffer, 0, count);
    }
    return bytes.toByteArray();
  } finally {
    try {
      // Close the InputStream and release the resources by "consuming the content".
      entity.consumeContent();
    } catch (IOException e) {
      // This can happen if there was an exception above that left the entity in
      // an invalid state.
      VolleyLog.v("Error occured when calling consumingContent");
    }
    mPool.returnBuf(buffer);
    bytes.close();
  }
}
origin: MewX/light-novel-library_Wenku8_Android

private void writeOneBuffer(ByteArrayPool pool) throws IOException {
  byte[] data = new byte[16384];
  for (int i = 0; i < data.length; i++) {
    data[i] = (byte) (i & 0xff);
  }
  PoolingByteArrayOutputStream os = new PoolingByteArrayOutputStream(pool);
  os.write(data);
  assertTrue(Arrays.equals(data, os.toByteArray()));
}
origin: chentao0707/SimplifyReader

@Override
public synchronized void write(byte[] buffer, int offset, int len) {
  expand(len);
  super.write(buffer, offset, len);
}
origin: cat9/EasyVolley

/** Reads the contents of HttpEntity into a byte[]. */
private byte[] entityToBytes(HttpEntity entity) throws IOException, ServerError {
  PoolingByteArrayOutputStream bytes =
      new PoolingByteArrayOutputStream(mPool, (int) entity.getContentLength());
  byte[] buffer = null;
  try {
    InputStream in = entity.getContent();
    if (in == null) {
      throw new ServerError();
    }
    buffer = mPool.getBuf(1024);
    int count;
    while ((count = in.read(buffer)) != -1) {
      bytes.write(buffer, 0, count);
    }
    return bytes.toByteArray();
  } finally {
    try {
      // Close the InputStream and release the resources by "consuming the content".
      entity.consumeContent();
    } catch (IOException e) {
      // This can happen if there was an exception above that left the entity in
      // an invalid state.
      VolleyLog.v("Error occured when calling consumingContent");
    }
    mPool.returnBuf(buffer);
    bytes.close();
  }
}
origin: chuyangliu/tastysnake

  private void writeBytesIndividually(ByteArrayPool pool) {
    byte[] data = new byte[16384];
    for (int i = 0; i < data.length; i++) {
      data[i] = (byte) (i & 0xff);
    }
    PoolingByteArrayOutputStream os = new PoolingByteArrayOutputStream(pool);
    for (int i = 0; i < data.length; i++) {
      os.write(data[i]);
    }

    assertTrue(Arrays.equals(data, os.toByteArray()));
  }
}
origin: jiangqqlmj/FastDev4Android

  @Override
  public synchronized void write(int oneByte) {
    expand(1);
    super.write(oneByte);
  }
}
origin: MewX/light-novel-library_Wenku8_Android

/** Reads the contents of HttpEntity into a byte[]. */
private byte[] entityToBytes(HttpEntity entity) throws IOException, ServerError {
  PoolingByteArrayOutputStream bytes =
      new PoolingByteArrayOutputStream(mPool, (int) entity.getContentLength());
  byte[] buffer = null;
  try {
    InputStream in = entity.getContent();
    if (in == null) {
      throw new ServerError();
    }
    buffer = mPool.getBuf(1024);
    int count;
    while ((count = in.read(buffer)) != -1) {
      bytes.write(buffer, 0, count);
    }
    return bytes.toByteArray();
  } finally {
    try {
      // Close the InputStream and release the resources by "consuming the content".
      entity.consumeContent();
    } catch (IOException e) {
      // This can happen if there was an exception above that left the entity in
      // an invalid state.
      VolleyLog.v("Error occured when calling consumingContent");
    }
    mPool.returnBuf(buffer);
    bytes.close();
  }
}
origin: MewX/light-novel-library_Wenku8_Android

  private void writeBytesIndividually(ByteArrayPool pool) {
    byte[] data = new byte[16384];
    for (int i = 0; i < data.length; i++) {
      data[i] = (byte) (i & 0xff);
    }
    PoolingByteArrayOutputStream os = new PoolingByteArrayOutputStream(pool);
    for (int i = 0; i < data.length; i++) {
      os.write(data[i]);
    }

    assertTrue(Arrays.equals(data, os.toByteArray()));
  }
}
origin: jiangqqlmj/FastDev4Android

@Override
public synchronized void write(byte[] buffer, int offset, int len) {
  expand(len);
  super.write(buffer, offset, len);
}
origin: com.mcxiaoke.volley/library

/** Reads the contents of HttpEntity into a byte[]. */
private byte[] entityToBytes(HttpEntity entity) throws IOException, ServerError {
  PoolingByteArrayOutputStream bytes =
      new PoolingByteArrayOutputStream(mPool, (int) entity.getContentLength());
  byte[] buffer = null;
  try {
    InputStream in = entity.getContent();
    if (in == null) {
      throw new ServerError();
    }
    buffer = mPool.getBuf(1024);
    int count;
    while ((count = in.read(buffer)) != -1) {
      bytes.write(buffer, 0, count);
    }
    return bytes.toByteArray();
  } finally {
    try {
      // Close the InputStream and release the resources by "consuming the content".
      entity.consumeContent();
    } catch (IOException e) {
      // This can happen if there was an exception above that left the entity in
      // an invalid state.
      VolleyLog.v("Error occured when calling consumingContent");
    }
    mPool.returnBuf(buffer);
    bytes.close();
  }
}
com.android.volley.toolboxPoolingByteArrayOutputStream

Javadoc

A variation of ByteArrayOutputStream that uses a pool of byte[] buffers instead of always allocating them fresh, saving on heap churn.

Most used methods

  • <init>
    Constructs a new ByteArrayOutputStream with a default size of size bytes. If more than size bytes ar
  • toByteArray
  • write
  • close
  • expand
    Ensures there is enough space in the buffer for the given number of additional bytes.

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (ScheduledExecutorService)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • getSharedPreferences (Context)
  • PrintWriter (java.io)
    Prints formatted representations of objects to a text-output stream. This class implements all of th
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Collectors (java.util.stream)
  • JLabel (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now