So what I'm trying to do is I have a text file that has 5580 lines and then has 9 columns separated by a , . I'm trying to have the user input an entry that will be in the first column and I need to search for that entry and pull the rest of the information. Java is new to me (I'm starting to miss fortran or python) any help?
1 Answer
Learn about input streams and readers. Here is some code sample that can be used by you to start.
String token = // init it
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileReader(thefileName)));
for (String line = reader.nextLine(); line !=null; line = reader.nextLine()) {
String[] parts = line.split(",");
if (token.equals(parts[0])) {
// this is the line you are looking for...
}
}