我想读取放在服务器中的二进制文件。我想要的是数据应该放在bytearray中。
以下是我的代码:
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();
但我没有得到正确的结果
答案 0 :(得分: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();