Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions