Is there a better way to read tokens in a file in java?
I am currently using StringTokenizer for splitting the tokens. But it can be quite inefficient in most cases as you have to read token by token.
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you look at
StringTokenizerin the Java API you will notice that it recommends an alternative:If neither of these options suit your needs, you should take a look at
Scanner, which also supports pattern matching: