No stack overflow since no stack is involved. Limit is 2 gigabytes: String length() returns an int and that's your limit. You will exhaust your memory before you exhaust the upper limit of a String. If you have more than a 10K string I suggest looking at alternative strategies to manage that memory.
The reason why i am using the string in this way is because the object that is returning the huge string is a document.
Why i need this is because i use this method to search the document for a certain string. Everything works but i am afraid that if the document returns a huge string from the document, i may actually exceed the limit.
On another issue i also felt that because the String object is immutable would it be better if i use the StringBuffer class as that does not create a copy of the string something like that
Would tis actually make a difference in that the String object is immutable and the StringBuffer object is mutable?