Java tutorial
//package com.java2s; import java.io.FileInputStream; import java.io.IOException; public class Main { /** * Read the original picture to an array * * @param initialFile * @param size * @return an array with the address and values */ public static int[] readBaseFile(String initialFile, int size) { int[] imageTxt = new int[size]; FileInputStream fin; try { // Open an input stream fin = new FileInputStream(initialFile); int k = 0; while (fin.available() != 0) { imageTxt[k++] = fin.read(); } fin.close(); } // Catches any error conditions catch (IOException e) { System.err.println("Unable to read image"); System.exit(1); } return imageTxt; } }