Question
java question there is a .txt file I want to read by using BufferedReader. how can I skip(don't read) a line starting with -? a
there is a .txt file I want to read by using BufferedReader.
how can I skip(don't read) a line starting with \"-\"?
a text file looks like...
/////////////////////////////////////////////////////////////////////////
- 3
- JD
- N123
KF
100
- DKK
53
Ju
//////////////////////////////////////////////////////////////////
the contents of file can be changed anytime, so, the logic to ignore line starting with \"-\" must be able to accepted.
I don't want to useif (string.charAt(0) == '-') continue;because I don't only want to print out all of them. I need to assign each value to another class's value. So, if-continue can skip first some lines starting with '-', but if that line appear in the middle again, I will not able to read each value to assign to somewhere.
So, we should suppose that '-' will be randomly placed in txt file.
Any better method to only ignore line starting with \"-\"??????
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started