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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:16:10+00:00 2026-05-22T21:16:10+00:00

Search string ‘4914904’ exists at the tail of the stream. Here’s the code Scanner

  • 0

Search string ‘4914904’ exists at the tail of the stream.

Here’s the code

    Scanner sc = new Scanner(xmlInputStream, "UTF-8");
    if(sc.findWithinHorizon('4914904', 0) != null) { // <--- exception is thrown here
    }

Any suggestions would be highly appreciated.

  • 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-05-22T21:16:11+00:00Added an answer on May 22, 2026 at 9:16 pm

    If you read the API for Scanner, you will see that if you pass the argument 0 to findWithinHorizon that it will read the entire buffer at once.

    Since you don’t do anything with the value from this I see a few options.

    Try changing to useDelimiter(String pattern) and then call if(sc.hasNext()) which may help some with the memory footprint.

    If you have XML, use an XML parser instead of a text scanner.

    You could consider writing a custom method which parses the input stream one line at a time and perform the search. That way you don’t have to read in the full buffer.

    Increase the memory you give the jvm when it starts -Xmx256m

    On a side note: Don’t re-write the code when you post here. Just copy and paste.

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

Sidebar

Related Questions

what is wrong with such code public List<SearchItem> Search(string find) { return (from i
I'm using a database for searching and facing following issue. When new search string
I am trying to get strpos to search string variable $string for the phrase
I have the following controller: public ActionResult Search(string Name, int? Friend, int? Page) It
I usually use the following pipeline to grep for a particular search string and
In eclipse, is it possible to use the matched search string as part of
I need to search a string and replace all occurrences of %FirstName% and %PolicyAmount%
I need to search a string in the string array. I dont want to
I often use the string search feature for an entire solution in VS2008. Is
When I try to search a string starting with the slash / character in

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.