Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8367101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:04:39+00:00 2026-06-09T13:04:39+00:00

I need to do processes on a file ,first count the number of lines

  • 0

I need to do processes on a file ,first count the number of lines and compare with a value.

The next is one to read thru the file line by line and do validations.

if first one passes only i need to do second process.

I read the same file using FTP.

When i try to create a different input stream…ftp is busy reading the current file.

like this :

(is1 = ftp.getFile(feedFileName);)

below is the remaining :

 InputStream is = null;
LineNumberReader lin = null;
    LineNumberReader lin1 = null;
is = ftp.getFile(feedFileName);  
lin = new LineNumberReader(new InputStreamReader(is));

so can i just use like below:

 is1=is;

Will both streams be having the file contents from start to finish or the second object will become null as soon as the first stream object is read.

So is the only option left is to create a new ftp object to read a stream seperately ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:04:40+00:00Added an answer on June 9, 2026 at 1:04 pm

    After you are done with the LineNumberReader, close the InputStream is. Then re-request the file from FTP, it will not be busy then anymore. You cannot ‘just’ read from the same InputStream, as that one is probably exhausted by the time the LineNumberReader is done. Furthermore, not all InputStreams support the mark() and reset() methods.

    However I’d suggest that doing the second process only when the first one succeeds might not be the right way. As you’re streaming the data anyways, why not stream it into a temporary data structure and then count the lines and then operate on the same data structure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to modify a text file from multiple .NET processes, nothing I've tried
I have a huge file and need to read it and process. with open(source_filename)
I need it to open 10 processes, and each time one of them finishes
I need to launch a number of long-running processes with subprocess.Popen , and would
Working on some import process where i need to first upload the file at
Here I have 2 requirements: Need a batch file to start a process on
I need a little nmake makefile for my build process. The file types are
I have a processes where I need to make ~100 http api calls to
I need to share a stack of strings between processes (possibly more complex objects
i need to write a program in c# to collect information about processes running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.