package cookiestore;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.io.IOException;


public class BinaryArrayPrinter extends Object
{

	private FileInputStream mReader;
	


	public BinaryArrayPrinter(String filename)
	throws FileNotFoundException 
	{
		File f = null;
		try {
			f = new File(filename);
		} catch (NullPointerException x1) {
			throw new IllegalArgumentException("Geen geldige bestandsnaam");
		}
		mReader = new FileInputStream(f);
	}

	public void print(PrintStream out)
	throws IOException
	{
		int c;
		int col = 0;
		out.print("int[] bytes = new int[]{");
		while ((c = mReader.read()) != -1) {
			if ((col % 8) == 0) {
				out.print("\r\n\t");
			} else {
			}
			out.print(Integer.toString((char)c));
			out.print(", ");
			col++;
		}
		out.print("\r\n};");
	}

	public static void main(String[] argv)
	{
		if (argv.length == 0) {
			System.out.println("Geef een plaatje mee");
		}
		try {
			BinaryArrayPrinter r = new BinaryArrayPrinter(argv[0]);
			r.print(System.out);
		} catch (Exception x) {
			System.out.println(x.getClass().getName());
			System.out.println(": ");
			System.out.println(x.getMessage());
		}
	}
}

