Java tutorial
//package com.java2s; import android.os.Environment; import android.util.Log; import java.io.DataInputStream; import java.io.EOFException; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; public class Main { final private static String TAG = "IOHelper"; /** * Reads in model 83 points and returns a double array float containing the * coordinates x & y. */ public static float[][] readBinModel83Pt2DFloat(String dir, String fileName) { float[][] array2D = new float[83][2]; float x; int i = 0; File sdLien = Environment.getExternalStorageDirectory(); File inFile = new File(sdLien + File.separator + dir + File.separator + fileName); Log.d(TAG, "path of file : " + inFile); if (!inFile.exists()) { throw new RuntimeException("File doesn't exist"); } DataInputStream in = null; try { in = new DataInputStream(new FileInputStream(inFile)); } catch (FileNotFoundException e) { e.printStackTrace(); } try { while (true) { x = in.readFloat(); array2D[i][0] = x; x = in.readFloat(); array2D[i][1] = x; i++; } } catch (EOFException e) { try { Log.d(TAG, "close"); in.close(); } catch (IOException e1) { e1.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } finally { if (in != null) { try { //free ressources Log.d(TAG, "close"); in.close(); } catch (IOException e) { e.printStackTrace(); } } } return array2D; } }