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

  • Home
  • SEARCH
  • 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 8654585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:49:28+00:00 2026-06-12T14:49:28+00:00

I have a xml log that is modified constantly by another application; however my

  • 0

I have a xml log that is modified constantly by another application; however my Java code runs concurrently and checks for a couple of strings. I am using a SAX Parser. Now my question is will I have to have a new instance of a FileInputStream every time I loop through the file? How about the parser?

So let’s say:

while(notfound)
{
    FileInputStream fis = new FileInputStream(new File("c:/tmp/123.xml"));
    SaxParser.parse(fis, sampleHandler);
    notFound = sampleHandler.checkIfFound();
}

Thanks 😀

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

    In the example you provided, you will need a new FileInputStream each time you want to start reading from the beginning of the file. Stream classes don’t often allow for manual positioning/resetting of the ‘location’, as since the name (‘Stream’) implies, it’s just a pipe with bits spewing out of it.

    Since you’re using the SaxParser.parse() class method to initiate the parsing, it doesn’t seem as though you actually have a parser object to re-create. So you should be fine with just re-creating the FileInputStream.

    But! It seems like current versions of the SaxParser class support passing in a File instance as the first parameter, so you can just repeatedly use:

    while(notfound)
    {
        SaxParser.parse(new File("c:/tmp/123.xml"), sampleHandler);
        notFound = sampleHandler.checkIfFound();
    }
    

    Avoiding the re-creation of the FileInputStream altogether, and allowing the parser to handle that.

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

Sidebar

Related Questions

I have some Java code that validates XML against an XSD. I am using
I have a java application build upon Spring 3. This project has another jar
I have a windows service that writes out log file entries to an XML
I have a makefile with rules that look like this: data/foo-trunk.xml: svn log -v
I have a log file that is being written using a defined slf4j XML
I have XML in the following form that I want to parse with PHP
I have XML that looks like this: <Parameter Name=parameter name Value=parameter value /> which
I have XML that looks like this: <ROW ref=0005631 type=04 line=1 value=Australia/> <ROW ref=0005631
I have a log file that looks like the following: 2010-05-12 12:23:45 Some sort
I have a program that periodically polls a certain folder for log files. When

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.