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 7995725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:30:24+00:00 2026-06-04T14:30:24+00:00

I have servlet to read log file my jsp call servlet at some interval.I

  • 0

I have servlet to read log file my jsp call servlet at some interval.I want to add functionality in my servlet so that it read file from line next to last line from previous read.

I have following code but its not working

File file = new File("D:\\graph\\temp.log");
FileReader fr = new FileReader(file);
LineNumberReader lnr = new LineNumberReader(fr);\

lnr.setLineNumber(count)  // count is the variable keeping track of number of line  
                             previously read.

Is it need some extra code ? or is there any other alernative to do the same ?

  • 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-04T14:30:25+00:00Added an answer on June 4, 2026 at 2:30 pm

    From the documentation:

    Note however, that setLineNumber(int) does not actually change the
    current position in the stream; it only changes the value that will be
    returned by getLineNumber().

    Sounds to me like you’ll have to start from the beginning and call readLine in a loop until getLineNumber() is greater than count.

    Something like this:

    File file = new File("D:\\graph\\temp.log");
    FileReader fr = new FileReader(file);
    LineNumberReader lineReader = new LineNumberReader(fr);
    
    // skip the lines you don't need 
    
    while (lineReader.getLineNumber() < count) {
        lineReader.readLine();
    }
    
    // begin processing input here 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

let's say i have a servlet that forwards a request to a jsp file
I have a servlet that users post a XML file to. I read that
I have a Servlet called Menu that generates some html and a dynamic menu,
I have a servlet that construct response to a media file request by reading
I want to build a very simple servlet that will read the http posted
I have a file upload form that is being posted back to a servlet
i read that inside the webserver a jsp page is converted to a servlet.
I have a servlet that allows users to download (potentially large) zip files from
I have a servlet that sends a file by setting the HTTP Content-Type to
I have to read a file using servlet.here is the code iam using.but file

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.