Can any one tell me, what i have to do if the String Object holds data more than 20-22MB of data. The string object holds that much of data and then the same data have to be displayed in a text area. i am doing something like this:
I'm not sure I totally understand the question, but as far as I know the size of a String is limited only by the resources of the machine. Looking at your code, my biggest suggestion would be to use TextArea's append() method directly. Hope that helps.
That is probably a bad idea. Depending on the JVM implementation, it is likely that creating a 22MB string will attempt to create a contiguous chunk of memory on the heap. This will probably result in swapping, and the performance of your application will be crap. If you are doing a lot of string manipulations, it will be even worse. Every time you do change the string, it will try to allocate another 22MB to hold the changed data. You could have the VM holding on to hundreds of MB at once. Think about what you are trying to achieve. If you are writing a text editor, for instance, maybe holding each line in a separate string is the best approach. Java has great features for memory management (like automatic GC), but you still need to understand basic computer science principles if you want to write efficient code.