Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is there a maximum allowable String length?

 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know if there is a limit on the length of Strings in j2me (or java, generally)?

I am designing a midlet that will retrieve a very long String from a server, and just want to make sure that it is possible first.

Thanks,
James
[ September 01, 2004: Message edited by: James Hodgkiss ]
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am just guessing here: Since Java use a char array to store strings and the array size cannot be larger than Integer.MAX_VALUE, I guess the string cannot have more than Integer.MAX_VALUE (about 64k) chars either.
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But you can always read the stream chunk by chunk and assemble them into multiple strings.
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael,

I have also found a thread at

http://www.coderanch.com/t/373885/java/java/many-bytes-String-object-contain

which also has some good info, in case anyone wants to know about this.

Cheers,
James
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic