Refine search
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; }
BufferedInputStream bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(bis.count); int current = 0; while ((current = bis.read()) != -1) { baf.append((byte)current); } byte[] imageData = baf.toByteArray();
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(); }
private class DownloadFileTask extends AsyncTask<URL, Integer, Long> { protected Long doInBackground(URL... urls) { Url url = urls[0]; //connect to url here ....... try { InputStream myInput = urlconnect.getInputStream(); BufferedInputStream buffinput = new BufferedInputStream(myInput); ByteArrayBuffer baf = new ByteArrayBuffer(capacity); int current = 0; while((current = buffinput.read()) != -1) { baf.append((byte) current); //here you can send data to onProgressUpdate publishProgress((int) (((float)baf.length()/ (float)sizefile) * 100)); } File outputfile = new File(createRepertory(app, 0), Filename); FileOutputStream myOutPut = new FileOutputStream(outputfile); myOutPut.write(baf.toByteArray()); ... } protected void onProgressUpdate(Integer... progress) { //here you can set progress bar in UI thread progressBarStatus = progress; }
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 baf = new ByteArrayBuffer(5000); int current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); fos.write(baf.toByteArray()); fos.flush(); fos.close();
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();
ByteArrayBuffer buffer = new ByteArrayBuffer(readBufferLength); dataLength = maxBytes - buffer.length(); buffer.append(tmpBuff, 0, dataLength); if (truncated) { break; return buffer.toByteArray();
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[] 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; }
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;
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);
public BinaryXmlParser(InputStream input) throws IOException { ByteArrayBuffer content = new ByteArrayBuffer(1024); int size; byte[] buffer = new byte[1024]; while (-1 != (size = input.read(buffer))) { content.append(buffer, 0, size); } mData = content.toByteArray(); input.close(); }
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);
InputStream is = getResources().openRawResource(R.raw.troodon_ph); BufferedInputStream bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; try { while ((current = bis.read()) != -1) { baf.append((byte) current); } } catch (IOException e) { e.printStackTrace(); } byte[] data = baf.toByteArray();
URL url = new URL(yoururl); InputStream input=url1.openStream(); BufferedInputStream bis=new BufferedInputStream(input); ByteArrayBuffer baf=new ByteArrayBuffer(1000); while((k=bis.read())!=-1) { baf.append((byte)k); } String data=new String(baf.toByteArray());
InputStream is =getResources().openRawResource(R.raw.song); BufferedInputStream bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); } byte[] myData = baf.toByteArray(); String dataInString = new String(myData); String[] words = dataInString.split(" ");
BufferedInputStream bis=new BufferedInputStream(inputstream); ByteArrayBuffer baf=new ByteArrayBuffer(1000); while((k=bis.read())!=-1) { baf.append((byte)k); } String results=new String(baf.toByteArray());
URL updateURL = new URL(urlstr); URLConnection conn = updateURL.openConnection(); InputStream is = conn.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(100); int current = 0; while((current = bis.read()) != -1){ baf.append((byte)current); } String html = new String(baf.toByteArray());
URL url = new URL(yoururl); InputStream input=url.openStream(); BufferedInputStream bis=new BufferedInputStream(input); ByteArrayBuffer baf=new ByteArrayBuffer(1000); while((k=bis.read())!=-1) { baf.append((byte)k); } String responsedata=new String(baf.toByteArray());