I'm a java beginner and I have a small question about scanning from a text file Suppose I have a text file like this
abc
012
4g5
(0 0 0)
(0 1 3)
(1 2 6)
(1 1 0)
abcde
blahblah
Now I want to make an array for ONLY the string inside the parenthesis, meaning that how to tell the scanner to scan only the strings started from the first open parentheses, reset the array input after the following right parentheses, and eventually stop scanning after the last right parentheses. This is what I have so far:
*for the array, it will take the first digit as the row#, second digit as the col# and the third digit as the value
while (file.hasNext()) {
if (file.next().equals("(")) {
do {
2Darray[Integer.parseInt(file.next())][Integer.parseInt(file.next())] = file.next();
}
while (!file.next().equals(")"));
}
thanks