I want to load a model file that will be present in the user's external storage. Size of the model file can be upto 20MB or so. It contains x,y,z info separated by '\n'. When i try to load a small file by my method it runs fine. But for a large file the application asks for a force quit.
File dir = Environment.getExternalStorageDirectory();
File file = new File(dir,"model_Cube.txt");
BufferedReader reader = null;
List<Float> list = new ArrayList<Float>();
try {
reader = new BufferedReader(new FileReader(file));
String text = null;
while ((text = reader.readLine()) != null) {
list.add(Float.parseFloat(text));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}
try {
reader.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
reader.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
triangleCoords = new float[list.size()];
for (int i = 0; i < list.size(); i++) {
Float f = list.get(i);
triangleCoords[i] = (float) (f.floatValue()/10.0); // Or whatever default you want.
}