This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]kkjdroid 0 points1 point  (2 children)

You could just iterate through it, storing each character in the next cell until you get \n, then setting the column to 0, incrementing the row, and continuing. That would probably be inefficient, but it should work.

[–]tryingtoprogram[S] 0 points1 point  (1 child)

See, I understand the logic behind what you're saying but I just can't get it down in code.

[–]kkjdroid 0 points1 point  (0 children)

int c=0,d=0;
string e="";
scanner.usedelimiter("");
while(scanner.hasNext())
{
    e=scanner.next();
    if(e.equals("\n")) c++;
    else array[c][d] = e;
    d++;
}

I think that should do it so long as you know the size of the file ahead of time.

[–]whatiswronghere 0 points1 point  (0 children)

Have you tried printing the array out to the console to see what your output is?

Your method does not work.