/    Sign up×
Community /Pin to ProfileBookmark

reset the inputstream to read again

I need to read the text file.

In order to identify number of rows in text file.
I need to execute the while loop for first time.

if there less then 10 rows then i need to execute while again for reading content in each row.

With below code i am unable to execute second.
How to mark to first postion of stream for executing second while.

What is best way to do this


——————————————-

if(stream!=null)
inReader = new BufferedReader(new InputStreamReader(inputStream ));
while ((strTemplateRow = inReader.readLine()) != null){ //first while

……
}

execution of while again

while ((strTemplateRow = inReader.readLine()) != null){ //second while

……
}

to post a comment
Java

1 Comments(s)

Copy linkTweet thisAlerts:
@CytaelMay 15.2006 — check out the API for BufferedReader:

http://java.sun.com/j2se/1.5.0/docs/api/java/io/BufferedReader.html

Looks like the mark and reset functions should serve you well.
×

Success!

Help @raghu123 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...