Hello all,
I am having some trouble I hope you can help me out with. I am trying to input a list of text, which has the name of a sub, the hull number, and the homeport of the sub, like this:
USS West Virginia [SSBN-736] Kings Bay, Georgia
a bunch of those lines. I am having trouble on how to break up the individual pieces of the lines of the text. Sometimes it is USS West Virginia, sometimes USS Indiana, and then sometimes the homeport will be Pearl Harbor, but others Kings Bay, Georgia. so the way I have used with the delimiter " " does not always work for everything. Can anything suggest what I could do to make this work all the time? the hull number will always have [] around the name if that helps....
this is what I have so far but it does not work for me:
try{
while(fileInput.ready()){
tempString = fileInput.readLine();
Scanner scanner = new Scanner(tempString);
scanner.useDelimiter(" ");
if(scanner.hasNext()){
StringBuffer subName = new StringBuffer("");
StringBuffer homePort = new StringBuffer("");
subName.append(scanner.next()).append(" ");
subName.append(scanner.next());
String hullNumber = scanner.next();
homePort.append(scanner.next()).append(" ");
homePort.append(scanner.next());