Roberto Vasquez Roberto Vasquez - 4 months ago 15x
Java Question

Java error "Array required, but String found" while importing text file

I'm trying to import a tab delimited text file into an 2D array but when trying assign the values of the splitted String into the array i get the error "Array required, but String found".

Here is my code so far:

try {
FileReader fr = new FileReader ("Laberinto.txt");
BufferedReader br = new BufferedReader(fr);

String s,str;
String[] buffer;

int y=0;

while ((s=br.readLine())!= null){
StringBuilder builder = new StringBuilder();

for (int x=0;x<str.length();x++){


I get the error on the line

Also, I don't know if this helps at all but The file is basically a bunch of 1s and 0s that form a labyrinth (1 being the walls and 0 the corridors) delimited by tabulator.

Can somebody tell me what im doing wrong please?

Thanks in advanced!


str is a string - a line from your input... That's not what you wanted.

You need to parse your buffer:

for (int x=0;x<buffer.length();x++){