Refine search
BufferedInputStream bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(50); while ((current = bis.read()) != -1) { baf.append((byte) current); } FileOutputStream fos = new FileOutputStream(file); fos.write(buffer.toByteArray());
byte[] logoImage = getLogoImage(IMAGEURL); private byte[] getLogoImage(String url){ try { URL imageUrl = new URL(url); URLConnection ucon = imageUrl.openConnection(); InputStream is = ucon.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(500); int current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); } return baf.toByteArray(); } catch (Exception e) { Log.d("ImageManager", "Error: " + e.toString()); } return null; }
public static byte[] toByteArray(final HttpEntity entity) throws IOException { if (entity == null) { throw new IllegalArgumentException("HTTP entity may not be null"); } InputStream instream = entity.getContent(); if (instream == null) { return new byte[] {}; } if (entity.getContentLength() > Integer.MAX_VALUE) { throw new IllegalArgumentException("HTTP entity too large to be buffered in memory"); } int i = (int)entity.getContentLength(); if (i < 0) { i = 4096; } ByteArrayBuffer buffer = new ByteArrayBuffer(i); try { byte[] tmp = new byte[4096]; int l; while((l = instream.read(tmp)) != -1) { buffer.append(tmp, 0, l); } } finally { instream.close(); } return buffer.toByteArray(); }
/* Open a connection to that URL. */ URLConnection ucon = url.openConnection(); ... ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); }
private static byte[] toByteArray(final HttpEntity entity) throws IOException { if (entity == null) { throw new IllegalArgumentException("HTTP entity may not be null"); } InputStream instream = entity.getContent(); if (instream == null) { return new byte[]{}; } if (entity.getContentLength() > Integer.MAX_VALUE) { throw new IllegalArgumentException("HTTP entity too large to be buffered in memory"); } int count = (int) entity.getContentLength(); if (count < 0) { count = 4096; } ByteArrayBuffer buffer = new ByteArrayBuffer(count); try { byte[] tmp = new byte[4096]; int len; while ((len = instream.read(tmp)) != -1) { buffer.append(tmp, 0, len); } } finally { instream.close(); } return buffer.toByteArray(); }
ByteArrayBuffer myBABuffer = new ByteArrayBuffer(50); int current = 0; while ((current = myBis.read()) != -1) { myBABuffer.append((byte) current); } FileOutputStream fos = new FileOutputStream(imgFile);
ByteArrayBuffer baf = new ByteArrayBuffer(5000); int current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); fos.write(baf.toByteArray()); fos.flush(); fos.close();
private static ByteArrayBuffer encode(final Charset charset, final String input) { final ByteBuffer encoded = charset.encode(CharBuffer.wrap(input)); final ByteArrayBuffer bab = new ByteArrayBuffer(encoded.remaining()); bab.append(encoded.array(), encoded.position(), encoded.remaining()); return bab; }
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); ByteArrayBuffer buffer = new ByteArrayBuffer(50); int current = 0; while ((current = bufferedInputStream.read()) != -1) { buffer.append((byte) current); stream.write(buffer.toByteArray()); stream.close();
private static ByteArrayBuffer encode( final Charset charset, final String string) { final ByteBuffer encoded = charset.encode(CharBuffer.wrap(string)); final ByteArrayBuffer bab = new ByteArrayBuffer(encoded.remaining()); bab.append(encoded.array(), encoded.position(), encoded.remaining()); return bab; }
ByteArrayBuffer buffer = new ByteArrayBuffer(readBufferLength); dataLength = maxBytes - buffer.length(); buffer.append(tmpBuff, 0, dataLength); if (truncated) { break; return buffer.toByteArray();
private static ByteArrayBuffer encode( final Charset charset, final String string) { final ByteBuffer encoded = charset.encode(CharBuffer.wrap(string)); final ByteArrayBuffer bab = new ByteArrayBuffer(encoded.remaining()); bab.append(encoded.array(), encoded.position(), encoded.remaining()); return bab; }
private byte[] getLogoImage(String url){ try { URL imageUrl = new URL(url); URLConnection ucon = imageUrl.openConnection(); InputStream is = ucon.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(500); int current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); } return baf.toByteArray(); } catch (Exception e) { Log.d("ImageManager", "Error: " + e.toString()); return null; } }
private static ByteArrayBuffer encode( final Charset charset, final String string) { ByteBuffer encoded = charset.encode(CharBuffer.wrap(string)); ByteArrayBuffer bab = new ByteArrayBuffer(encoded.remaining()); bab.append(encoded.array(), encoded.position(), encoded.remaining()); return bab; }
public static byte[] getLogoImage(String url){ try { URL imageUrl = new URL(url); URLConnection ucon = imageUrl.openConnection(); InputStream is = ucon.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(500); int current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); } return baf.toByteArray(); } catch (Exception e) { Log.d("ImageManager", "Error: " + e.toString()); } return null; }
private static ByteArrayBuffer encode( final Charset charset, final String string) { final ByteBuffer encoded = charset.encode(CharBuffer.wrap(string)); final ByteArrayBuffer bab = new ByteArrayBuffer(encoded.remaining()); bab.append(encoded.array(), encoded.position(), encoded.remaining()); return bab; }
ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; while((current = bis.read()) != -1){ baf.append((byte)current); String ret = new String(baf.toByteArray(),encoding); GlobalVars.LastError = ret; return true;
URL url = new URL("http://www.escapeguide.gr/en/rest/views/mobile_listings.json?display_id=sights_service"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); int status = connection.getResponseCode(); if (status == HttpURLConnection.HTTP_OK) { InputStream is = new BufferedInputStream(connection.getInputStream()); ByteArrayBuffer buffer = new ByteArrayBuffer(4096); int byteCount = 0; byte[] bytes = new byte[4096]; do buffer.append(bytes, 0, byteCount); while ((byteCount = is.read(bytes)) != -1); } JSONArray array = new JSONArray(new String(buffer));
InputStream is = connection.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is, 8190); ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; while ((current = bis.read()) != -1) { baf.append((byte)current); } byte[] imageData = baf.toByteArray(); BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
byte[] readBytes ; // Your byte array .... //for eg. readBytes = "TestBytes".getBytes(); ByteArrayBuffer mReadBuffer = new ByteArrayBuffer(0 ) ; // Instead of 0, if you know the count of expected number of bytes, nice to input here mReadBuffer.append(readBytes, 0, readBytes.length); // this copies all bytes from readBytes byte array into mReadBuffer // Any new entry of readBytes, you can just append here by repeating the same call. // Finally, if you want the result into byte[] form: byte[] result = mReadBuffer.buffer();