tags:

views:

176

answers:

2

I recently ran into an issue with Groovy where I was attempting to deal with a very large string (100k characters). I got an error that said the string could not be more than 65,535 characters. I did some searches to try to find out more info and ran across this link that said the problem was with the JVM - http://jira.codehaus.org/browse/GROOVY-2382.

I thought Java ran on the JVM as well and in Java I have had much larger strings. Just trying to understand. Can anyone shed some light on this for me. Thank you in advance.

Sean

+4  A: 

Looking at the source for java.lang.String the limit is that of Integer.MAX_VALUE which is pretty big.

So yes there is a limit but 100K is no where near it.

The limit that the Groovy bug refers to it that of a string literal, this isn't the same as creating a very big string.

Gareth Davis
+4  A: 

This is a limitation on string literals, i.e. Strings in the source code.

It is not a problem for Strings read from a File or some other InputStream.

You should move your huge String into a separate text file.

Thilo