First page Back Continue Last page Overview Graphics
Reading a file of integers (The hard way)
public static int[] readNumbersFromFile
- ( String fileName, int n) throws IOException{
- int[] arr = new int[n];
- FileInputStream fileIn= new FileInputStream(fileName);
- int currByte;
- int currInt; int base = 8;
- for(int i = 1; i < n; i++){
- for (int j = 3; j >= 0; j--)
- currInt = s |
- ( unsignedByteToInt(fileIn.read()) << base*j );
- }
- fileIn.close();
- }