Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import java.io.FileInputStream; import java.io.StringWriter; public class Main { public static int[] fileToIntArray(Context myContext, String filename, int size) { int[] array = new int[size]; int i = 0; FileInputStream inputStream; try { int c; inputStream = myContext.openFileInput(filename); StringWriter writer = new StringWriter(); while ((c = inputStream.read()) != -1) { writer.append((char) c); } String ints[] = writer.toString().split("\n"); for (String s : ints) { array[i++] = Integer.parseInt(s); } } catch (Exception e) { e.printStackTrace(); } return array; } }