package com.brainfucker;

class BrainfuckRunner {

    private char[] data;

    private String program;

    private String args;

    // Points to current index in data
    private int pointerIndex;

    private String output;

    private static final int ARRAYSIZE = 30000;

    private static class Token {
	public static final char NEXT = '>';
	public static final char PREV = '<';
	public static final char INC = '+';
	public static final char DEC = '-';
	public static final char PRINT = '.';
	public static final char INPUT = ',';
	public static final char BRAC_LEFT = '[';
	public static final char BRAC_RIGHT = ']';
    }

    public BrainfuckRunner(String program){
	initialize();
	this.program = program;
    }

    public BrainfuckRunner(String program, String args){
	this(program);
	this.args = args;
    }

    private void initialize(){
	data = new char[ARRAYSIZE];
	pointerIndex = 0;
	output = "";
	args = null;
    }
    
    
}

package com.brainfucker;

class BrainfuckRunner {

    private char[] data;

    // Points to current index in data
    private int dataPtr;

    private int argPtr;

    // Excecution is at this colunm
    private int executeCol;

    private String prog;
    
    private String args;

    private String output;

    private static final int ARRAYSIZE = 30000;

    private static final int MAX_CHAR_NUM = 300;

    private static class Token {
	public static final char NEXT = '>';
	public static final char PREV = '<';
	public static final char INC = '+';
	public static final char DEC = '-';
	public static final char PRINT = '.';
	public static final char INPUT = ',';
	public static final char BRAC_LEFT = '[';
	public static final char BRAC_RIGHT = ']';
    }

    public BrainfuckRunner(){
	clean();
    }

    private void clean(){
	data = new char[ARRAYSIZE];
	dataPtr = 0;
	argPtr = 0;
	executeCol = 0;
	args = "";
	output = "";
    }

    private void run(String program){
	
	
    }

    private void interperateChar(char c, int progLoc) throws Exception {
	switch(c){
	case Token.NEXT:
	    if(dataPtr + 1 < data.length){
		dataPtr++;
	    } else {
		throw new Exception("Out of bounds, too big @" + executeCol);
	    }
	    break;
	case Token.PREV:
	    if(dataPtr - 1 >= 0){
		dataPtr--;
	    } else {
		throw new Exception("Out of bounds, too small @" + executeCol);
	    }
	    break;
	case Token.INC:
	    if(data[dataPtr] < MAX_CHAR_NUM){
		data[dataPtr]++;
	    } else {
		throw new Exception("Out of bounds on data, too big @" + executeCol);
	    }
	    break;
	case Token.DEC:
	    if(data[dataPtr] > 0){

	    } else {
		throw new Exception("Out of bounds on data:" + dataPtr + ", too big @" + executeCol);
	    }
	    break;
	case Token.PRINT:
	    output += dataPtr;
	    break;
	case Token.INPUT:
	    data[dataPtr] = args.charAt(argPtr);
	    break;
	case Token.BRAC_LEFT:
	    if(data[dataPtr] > 0){
		//backup data ptr
		int dpt = dataPtr;
   		while(data[dataPtr] > 0){
		    int rightBracLoc = -1;
		    for(int i = prog.length(); i > progLoc; i--){
			if(prog.charAt(i) == Token.BRAC_RIGHT){
			    rightBracLoc = i;
			} else {
			    // No matching bracket
			    throw new Exception("Brackets are fucked @" + dataPtr);
			}
		    }
		    // Right bracket found or exception thrown
		    // Run middle part
		    for(int p = dataPtr + 1; p < rightBracLoc; p++){
			interperateChar(prog.charAt(p), p);
		    }
		    
		}
	    }
	    break;
	case Token.BRAC_RIGHT:
	    //Should never happen, fingers crossed
	    break;
	default:
	    throw new Exception("Invalid char @" + executeCol);
	    	}
    }
    
}

Add integral BrainfuckRunner code, might contain bugs