Help, processing strings >32K

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • D

    Help, processing strings >32K

    Hi folks,
    This may be pretty simple for you guys but it has me stumped.

    BTW I'm using Java 1.1, I know it's old, don't ask me why, I just have to.

    I have a long string in excess of 50k that I need to process in 32k chunks.
    The problem is all string processing in Java is done with integers. Is
    there an easy way to stream multiple 32k chunks of information from a
    string/array into a holding string/array?

    Thanks

    Dave


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.542 / Virus Database: 336 - Release Date: 18/11/2003


  • glen herrmannsfeldt

    #2
    Re: Help, processing strings >32K

    D wrote:
    [color=blue]
    > Hi folks,
    > This may be pretty simple for you guys but it has me stumped.
    >
    > BTW I'm using Java 1.1, I know it's old, don't ask me why, I just have to.
    >
    > I have a long string in excess of 50k that I need to process in 32k chunks.
    > The problem is all string processing in Java is done with integers. Is
    > there an easy way to stream multiple 32k chunks of information from a
    > string/array into a holding string/array?[/color]

    Java int variables are 32 bit, so they can hold numbers much larger than
    32k. As string objects have a length, you can store any character in
    them, unlike in C. There might be a restriction on String constants,
    though I can't think of one right now.

    What is it that you can't get it to do?

    -- glen

    Comment

    • Anthony Borla

      #3
      Re: Help, processing strings >32K


      "D" <noone@nowhere. COM> wrote in message
      news:3fbfae57$0 $28689$cc9e4d1f @news.dial.pipe x.com...[color=blue]
      > Hi folks,
      > This may be pretty simple for you guys but it has me
      > stumped.
      >
      > BTW I'm using Java 1.1, I know it's old, don't ask me
      > why, I just have to.
      >[/color]

      Fair enough, all problems must be solved given constraints [specified, or
      impleid], so I guess the challenge is to find the 'best' [very relative !]
      solution within the given constraints.
      [color=blue]
      >
      > I have a long string in excess of 50k that I need to process in
      > 32k chunks. The problem is all string processing in Java is
      > done with integers. Is there an easy way to stream multiple
      > 32k chunks of information from a string/array into a holding
      > string/array?
      >[/color]

      Have you looked at using 'StringReader' / 'StringWriter', and
      'CharArrayReade r' / 'CharArrayWrite r', all available in 1.1 ?

      I hope this helps.

      Anthony Borla


      Comment

      • D

        #4
        Thanks Glen and Anthony. More info was (Help, processing strings &gt;32K)

        Hi Glen, Anthony.
        I'm currently looking at streams to solve this problem, probably the main
        issue is that I don't come from an OO background.
        Anyway the problem I have is this:
        I have a large string (say 100000 bytes) passed into my routine. I need to
        read this entire string in blocks of 32000 bytes as these will be passed to
        another routine for further processing.
        Now with my limited Java experience my thinking was to use String.substrin g
        to chop out the necessary sections of data but of course you can't specify a
        starting position greater than the size of an integer so I'm looking at
        streams and readers now but I don't know any techniques for doing what I
        need.

        So what I need is some way of streaming in 32000 bytes of the string to
        another array or string and repeat until the end of the string is reached.

        Many thanks

        Dave


        ---
        Outgoing mail is certified Virus Free.
        Checked by AVG anti-virus system (http://www.grisoft.com).
        Version: 6.0.542 / Virus Database: 336 - Release Date: 18/11/2003


        Comment

        • Silvio Bierman

          #5
          Re: Thanks Glen and Anthony. More info was (Help, processing strings &gt;32K)


          "D" <noone@nowhere. COM> wrote in message
          news:3fbfe8c6$0 $28690$cc9e4d1f @news.dial.pipe x.com...[color=blue]
          > Hi Glen, Anthony.
          > I'm currently looking at streams to solve this problem, probably the main
          > issue is that I don't come from an OO background.
          > Anyway the problem I have is this:
          > I have a large string (say 100000 bytes) passed into my routine. I need[/color]
          to[color=blue]
          > read this entire string in blocks of 32000 bytes as these will be passed[/color]
          to[color=blue]
          > another routine for further processing.
          > Now with my limited Java experience my thinking was to use[/color]
          String.substrin g[color=blue]
          > to chop out the necessary sections of data but of course you can't specify[/color]
          a[color=blue]
          > starting position greater than the size of an integer so I'm looking at
          > streams and readers now but I don't know any techniques for doing what I
          > need.
          >
          > So what I need is some way of streaming in 32000 bytes of the string to
          > another array or string and repeat until the end of the string is reached.
          >
          > Many thanks
          >
          > Dave
          >
          >
          > ---
          > Outgoing mail is certified Virus Free.
          > Checked by AVG anti-virus system (http://www.grisoft.com).
          > Version: 6.0.542 / Virus Database: 336 - Release Date: 18/11/2003
          >
          >[/color]

          You still seem to have missed that Java integers are 32 bit so string
          lengths up to about 2000000000 characters are never a problem. Substring
          will work fine, although using strings for such long sequences of characters
          seems very inefficient.

          Silvio Bierman


          Comment

          Working...