0

I want to read binary file that is placed in server. what i want is data should be placed in bytearray.

Following is my piece of code:

BufferedReader in = new BufferedReader(new InputStreamReader(uurl.openStream()));

String str;
while ((str = in.readLine()) != null) {
    text_file=text_file+str;
    text_file=text_file+"\n";
}
m_byteVertexBuffer=text_file.getBytes();

But i am not getting correct result

Muneem Habib
  • 1,046
  • 4
  • 18
  • 49

1 Answers1

0

Try this: (it reads an image, but could modified to read generic binaries)

        aURL = new URL(imageUrl);
        URLConnection conn = aURL.openConnection();
        InputStream is = new BufferedInputStream(conn.getInputStream()); 
        BitmapFactory.Options options = new BitmapFactory.Options();
        is = new BufferedInputStream(conn.getInputStream()); 
        bm = BitmapFactory.decodeStream(is, null, options); 
        is.close(); 
Martin
  • 4,711
  • 4
  • 29
  • 37