List of usage examples for org.apache.http.util ByteArrayBuffer buffer
null buffer
To view the source code for org.apache.http.util ByteArrayBuffer buffer.
Click Source Link
From source file:android.wulongdao.thirdparty.mime.HttpMultipart.java
private static void writeBytes(final ByteArrayBuffer b, final OutputStream out) throws IOException { out.write(b.buffer(), 0, b.length()); }
From source file:cn.isif.util_plus.http.client.multipart.HttpMultipart.java
private static void writeBytes(final ByteArrayBuffer b, final OutputStream out) throws IOException { out.write(b.buffer(), 0, b.length()); out.flush();/*from w ww .j a v a2s. co m*/ }
From source file:topoos.APIAccess.mime.HttpMultipart.java
/** * Write bytes.//from w ww . j a va 2 s .co m * * @param b the b * @param out the out * @throws IOException Signals that an I/O exception has occurred. */ private static void writeBytes(final ByteArrayBuffer b, final OutputStream out) throws IOException { out.write(b.buffer(), 0, b.length()); }
From source file:Main.java
public static byte[] hexToBytes(String hex) { ByteArrayBuffer bytes = new ByteArrayBuffer(hex.length() / 2); for (int i = 0; i < hex.length(); i++) { if (hex.charAt(i) == ' ') { continue; }/* w ww .ja v a 2 s . c om*/ String hexByte; if (i + 1 < hex.length()) { hexByte = hex.substring(i, i + 2).trim(); i++; } else { hexByte = hex.substring(i, i + 1); } bytes.append(Integer.parseInt(hexByte, 16)); } return bytes.buffer(); }
From source file:mtmo.test.mediadrm.Utils.java
public static byte[] readIPMPDataFromFile(boolean isVideo) { ByteArrayBuffer buffer = new ByteArrayBuffer(0); FileInputStream fis = null;//from w w w .j a va2 s .co m byte[] buff = new byte[1024]; int ret = 0; File file = null; String path; if (isVideo) { path = VIDEO_SINF; } else { path = AUDIO_SINF; } file = new File(path); if (!file.exists()) { return null; } try { fis = new FileInputStream(file); while ((ret = fis.read(buff)) > 0) { buffer.append(buff, 0, ret); } } catch (IOException e) { return null; } finally { if (fis != null) { try { fis.close(); } catch (IOException e) { } fis = null; } } return buffer.buffer(); }
From source file:mtmo.test.mediadrm.Utils.java
public static byte[] readPsshDataFromFile(boolean isVideo) { ByteArrayBuffer buffer = new ByteArrayBuffer(0); FileInputStream fis = null;/*from www . j a v a2 s. com*/ byte[] buff = new byte[1024]; int ret = 0; File file = null; String path; if (isVideo) { path = VIDEO_PSSH; } else { path = AUDIO_PSSH; } file = new File(path); if (!file.exists()) { return null; } try { fis = new FileInputStream(file); while ((ret = fis.read(buff)) > 0) { buffer.append(buff, 0, ret); } } catch (IOException e) { return null; } finally { if (fis != null) { try { fis.close(); } catch (IOException e) { } fis = null; } } return buffer.buffer(); }
From source file:de.tlabs.ssr.g1.client.XMLChunkInputStream.java
public XMLChunkInputStream(ByteArrayBuffer arrayBuffer, InputStream inputStream) { super(arrayBuffer.buffer()); this.arrayBuffer = arrayBuffer; this.inputStream = inputStream; this.tempBuffer = new byte[TEMPBUFFERSIZE]; this.tempBufferStart = 0; this.tempBufferEnd = 0; }
From source file:com.sonyericsson.android.drm.drmlicenseservice.DLSHttpClient.java
private static void writeDataToFile(String suffix, ByteArrayBuffer data) { if (Constants.DEBUG) { File dir = new File(Environment.getExternalStorageDirectory() + "/dls"); if (!dir.exists() && !dir.mkdirs()) { return; }//from w w w . j a va 2s . com String datestr = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss.SSS-", Locale.US).format(new Date()); File f = new File(Environment.getExternalStorageDirectory() + "/dls/" + datestr + suffix + ".xml"); if (data != null) { try { FileOutputStream fos = new FileOutputStream(f); try { fos.write(data.buffer(), 0, data.length()); } finally { fos.close(); } } catch (FileNotFoundException e) { DrmLog.logException(e); } catch (IOException e) { DrmLog.logException(e); } } else { try { f.createNewFile(); } catch (IOException e) { DrmLog.logException(e); } } } }
From source file:org.mycard.net.network.LoadListener.java
protected void handleData(Message msg) { int len = msg.arg1; int totalLen = msg.arg2; ByteArrayBuffer buffer = (ByteArrayBuffer) msg.obj; try {//from w w w . j a v a 2 s . co m synchronized (mDataBuffer) { mDataBuffer.append(buffer.buffer(), 0, buffer.length()); } } catch (OutOfMemoryError error) { cancel(); HttpTaskEventArg arg = new HttpTaskEventArg(); arg.mErrorId = HttpTaskListener.ERROR_OUT_OF_MEMORY; mTaskListener.onHttpTaskEvent(m_taskid, HttpTaskListener.HTTPTASK_EVENT_FAIL, arg); return; } if (mTaskListener != null) { if ((mStatusCode >= 301 && mStatusCode <= 303) || mStatusCode == 307) { // } else { HttpTaskEventArg arg = new HttpTaskEventArg(); arg.mlen = len; arg.mTotal = totalLen; arg.buffer = buffer.buffer(); mTaskListener.onHttpTaskEvent(m_taskid, HttpTaskListener.HTTPTASK_EVENT_DATARECIVE, arg); } } }
From source file:cn.edu.zzu.wemall.http.AsyncHttpResponseHandler.java
byte[] getResponseData(HttpEntity entity) throws IOException { byte[] responseBody = null; if (entity != null) { InputStream instream = entity.getContent(); if (instream != null) { long contentLength = entity.getContentLength(); if (contentLength > Integer.MAX_VALUE) { throw new IllegalArgumentException("HTTP entity too large to be buffered in memory"); }//from w w w .j a v a2 s .co m if (contentLength < 0) { contentLength = BUFFER_SIZE; } try { ByteArrayBuffer buffer = new ByteArrayBuffer((int) contentLength); try { byte[] tmp = new byte[BUFFER_SIZE]; int l, count = 0; // do not send messages if request has been cancelled while ((l = instream.read(tmp)) != -1 && !Thread.currentThread().isInterrupted()) { count += l; buffer.append(tmp, 0, l); sendProgressMessage(count, (int) contentLength); } } finally { instream.close(); } responseBody = buffer.buffer(); } catch (OutOfMemoryError e) { System.gc(); throw new IOException("File too large to fit into available memory"); } } } return responseBody; }