0

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 1

1

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...
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.