scanning patterns
Hello,
trying to figure out scanner patterns...actually, reading text file with information and would like to store string which is between triangle brackets <Hello> into a veriable.
code i have so far
import java.util.*;
import java.io.File;
import java.io.FileNotFoundException;
public class DataScanner {
private static void readFile(String fileName) {
try {
Scanner scanner =
new Scanner(new File(fileName));
scanner.useDelimiter
(System.getProperty("line.separator"));
while (scanner.hasNext()) {
parseLine(scanner.next());
}
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
}
private static void parseLine(String line) {
Vector myStations = new Vector(); // collection of stations
Scanner lineScanner = new Scanner(line);
lineScanner.useDelimiter("\\s*,\\s*");
Scanner test = new Scanner(line);
test.findInLine(?);// trying to identify string between <> brackets
String stationname = lineScanner.next();
String linename = test.next();
int x = lineScanner.nextInt();
int y = lineScanner.nextInt();
myStations.add(new Station(x, y, stationname, linename));
System.out.println(myStations);
}
public static void main(String[] args) {
readFile("other.data");
}
}
Cheers, Stereocilia II

