By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,797 Members | 1,336 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,797 IT Pros & Developers. It's quick & easy.

Help, processing strings >32K

P: n/a
D
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
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
D wrote:
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?


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

Jul 17 '05 #2

P: n/a

"D" <no***@nowhere.COM> wrote in message
news:3f***********************@news.dial.pipex.com ...
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.

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.

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?


Have you looked at using 'StringReader' / 'StringWriter', and
'CharArrayReader' / 'CharArrayWriter', all available in 1.1 ?

I hope this helps.

Anthony Borla
Jul 17 '05 #3

P: n/a
D
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.substring
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
Jul 17 '05 #4

P: n/a

"D" <no***@nowhere.COM> wrote in message
news:3f***********************@news.dial.pipex.com ...
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.substring 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


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
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.