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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:02:40+00:00 2026-05-17T01:02:40+00:00

I have a large string (an RSS Article to be more precise) and I

  • 0

I have a large string (an RSS Article to be more precise) and I want to get the word in a specific startIndex and endIndex. String provides the substring method, but only using ints as its parameters. My start and end indexes are of type long.

What is the best way to get the word from a String using start and end indexes of type long?

My first solution was to start trimming the String and get it down so I can use ints. Didn’t like where it was going. Then I looked at Apache Commons Lang but didn’t find anything. Any good solutions?

Thank you.


Update:

Just to provide a little more information.

I am using a tool called General Architecture for Text Engineering (GATE) which scans a String and returns a list of Annotations. An annotation holds a type of a word (Person, Location, etc) and the start and end indexes of that word .

For the RSS, I use ROME, which reads an RSS feed and contains the body of the article in a String.

  • 1 1 Answer
  • 1 View
  • 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-17T01:02:40+00:00Added an answer on May 17, 2026 at 1:02 am

    There is no point doing this on a String because a String can hold at 2^31 - 1 characters. Internally the string’s characters are held in a char[], and all of the API methods use int as the type for lengths, positions and offsets.

    • The same restriction applied to StringBuffer or StringBuilder; i.e. an int length.
    • A StringReader is backed by a String, so that won’t help.
    • Both CharBuffer and ByteBuffer have the same restriction; i.e. an int length.
    • A bare array of a primitive type is limited to an int length.

    In short, you are going to have to implement your own “long string” type that internally holds its characters in (for example) an array of arrays of characters.

    (I tried a Google search but I couldn’t spot an existing implementation of long strings that looked credible. I guess there’s not a lot of call for monstrously large strings in Java …)

    By the way, if you anticipate that the strings are never going to be this large, you should just convert your long offsets to int. A cast would work, but you might want to check the range and throw an exception if you ever get an offset >= 2^31.

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

Sidebar

Related Questions

I have large String variable named text . I want to be able to
I have a large text string and about 200 keywords that I want to
Simple question: I have a large string that I want to write to a
I'm using .NET 2.0 I have a large array of string. I want to
I have a large string, where there can be specific words (text followed by
If I have a large string with multiple lines and I want to match
I have a large hex string abcdef... and I want to convert it to
I have a large map of String->Integer and I want to find the highest
I have a large string in a variable that includes a whole bunch of
I have a large string having dates, Ip addresses etc.. I need to split

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.