0

我想读取放置在服务器中的二进制文件。我想要的是数据应该放在字节数组中。

以下是我的一段代码:

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();

但我没有得到正确的结果

4

1 回答 1

0

试试这个:(它读取图像,但可以修改为读取通用二进制文件)

        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(); 
于 2013-08-20T15:55:06.157 回答