Re: DataInputStream
On 10/5/2011 10:17 AM, bob wrote:
On Oct 5, 2:07 am, Robert Klemme<shortcut...@googlemail.com> wrote:
On Oct 5, 8:17 am, bob<b...@coolgroups.com> wrote:
float[] getVertices3(String filename) {
try {
AssetManager am = this.getResources().getAssets();
InputStream is = am.open(filename);
DataInputStream dis = new DataInputStream(is);
int numfloats=dis.readInt();
float[] floatArray = new float[numfloats];
for (int ctr = 0; ctr< floatArray.length; ctr++) {
floatArray[ctr] = dis.readFloat();
}
return floatArray;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
That's OK. Now, what's the issue?
The issue is that it's too slow.
Rather unlikely that readFloat is the culprit.
Try replace:
InputStream is = am.open(filename);
DataInputStream dis = new DataInputStream(is);
with:
InputStream is = new BufferedInputStream(am.open(filename), 65536);
DataInputStream dis = new DataInputStream(is);
Arne