ArrayIndexOutOfBounds
in
Programming Questions
•
7 months ago
Hey guys,
Working on a task i've been set involving using the buffered reader to read in text from a file. The file has the format as followed:
x ## ## ## ##
where x is a letter and ## is a number. This has several lines all of which are consistent. However upon running the code i've put together i'm recieving an arrayindexoutofbounds error.
Any help identifying what i've managed to cock up would be greatly appreciated!
- String line;
- BufferedReader reader;
- int i = 0;
- class brick{
- int x,y,wid,hei;
- String type;
- }
- void setup(){
- background(#FFFFFF);
- size(500,500);
- rectMode(CORNERS);
- brick item;
- reader = createReader("breakout1.lvl");
- do{
- try{
- line = reader.readLine();
- String lap = line;
- i++;
- }
- catch(IOException e){
- e.printStackTrace();
- line = null;
- }
- if(line!=null){
- item = new brick();
- String[] pieces = split(line, TAB);
- item.type = (pieces[0]);
- item.x = int(pieces[1]);
- println(pieces[2]);
- item.y = int(pieces[2]);
- item.wid = int(pieces[3]);
- item.hei = int(pieces[4]);
- println(line);
- }
- }while(line!=null);
- }
1