UNB/ CS/ David Bremner/ teaching/ cs1083/ java/ PBM2.java
import java.util.Scanner;

public class PBM2 {
    private int[][] bits;
    private int rows,columns;
    PBM2() throws ImageFormatException{
        Scanner sc =
            new Scanner(System.in);
        if (!sc.next().equals("P1"))
            throw new ImageFormatException("Format error");
        columns=sc.nextInt();
        rows=sc.nextInt();
        bits=new int[rows][columns];
        for (int i=0; i< rows; i++){
            String line=sc.next();
            for (int j=0; j<columns; j++)
                bits[i][j]=line.charAt(j)-'0';
        }
    }
    public String toString(){
        String result="";
        for (int i=0; i< rows; i++){
            for (int j=0; j<columns; j++){
                if (bits[i][j]==1)
                    result += "*";
                else
                    result += " ";
            }
            result +="\n";
        }
        return result;

    }
    public static void main(String [] args) throws ImageFormatException{

        PBM2 pbm = new PBM2();
        System.out.println(pbm);
    }
}
//@keywords: array, 2D array, bitmap, file, image processing