Garg said:
Is there any variable in java like Stringbuffer which can handle GB's
of char data.
StringBuffer is a class, not a variable. I don't mean this just as a nitpick;
the way you describe a problem has a very large affect on the types of
answers you'll get.
If you're imprecise in describing what you're doing, and unclear in your
description of the Java language, you'll get general answers that assume
you're a fairly inexperienced developer. Which may be what you're looking
for
As far as i know every variable has a limit is there any variable
which can handle unlimited data.
Every computer has a limit. AFAIK, Java's limits for this kind of class are
based on available memory and the fact that arrays must be indexable by a
32-bit signed integer. I'll be surprised if someone says there's no JVM on
any hardware that can handle 1.8 billion characters in a StringBuilder.
But then you get into WHY you want to do such a thing.
it sounds little bit stupid but which data type or design pattern can
solve this problem.
Generally, look for ways to avoid having it all in memory at the same time.
If possible, a streaming approach is good: read from a file/socket a little at
a time, process it, and write to a file/socket. Alternately,
java.io.RandomAccessFile lets you seek() to the section you want to work on.
In both cases, you'll need to be careful about the distinction between bytes
and characters.