Reading a pgm file in Java
问题 I need to read a pgm file and store the array of values contained in it in a 2D array. In PGM format, each pixel is specified by a gray value between 0 and MaxVal. The first three lines give information related to the image: magic number, height, width and maxVal. The file also includes whitespaces. Lines starting with # are comments. This is what I had written till now. public class PGM{ public static void main(String args[]) throws Exception { FileInputStream f = new FileInputStream("C:\\..