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

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 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!