capacity « StringBuffer « Java Data Type Q&A





1. What is the capacity of a StringBuffer?    stackoverflow.com

When I run this code:

StringBuffer name = new StringBuffer("stackoverflow.com");
System.out.println("Length: " + name.length() + ", capacity: " + name.capacity());
it gives output:
Length: 17, capacity: 33
Obvious length is related to number of ...

2. StringBuffer capacity    coderanch.com

3. StringBuffer capacity    forums.oracle.com

4. Is there a maximum capacity for a StringBuffer ?    forums.oracle.com

For that amount of data, you want to use a streaming approach (like some of the examples in your earlier thread) rather than trying to buffer all the data (unless you're using a regex which requires to match widely separated data, which your examples didn't). For a simple string match, create a state machine and read one char at a time, ...