• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What's the maximum length of a string?

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to implement a simple e-mail sender application using Java Mail.
Suppose I am going to make it a web-based application implemented in servlet.
Suppose the web interface has a message text box, in which the user can
enter the e-mail message.
Now here is my question: Suppose the user types in a lengthy text message of size 5K bytes. I am assuming that this size is good enough for my
question. How do I grab such a lengthy text? Can I use String? Like this:
String msg=request.getParameter("emailMessage");
I doubt this will work.
I guess I can do it using BufferedReader, like so:
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
But, the problem is how can I send the message in the buffer by e-mail?
Thanks a lot.
[ April 01, 2002: Message edited by: Gene Chao ]
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mean "How long is a piece of String?"
Sorry, I couldn't resist
Dave
 
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might as well just go for the string.
A string can be pretty big. They're basically just over-glorified char[]'s. Since an array's size is of the type int, I'm guessing the maximum size of String is 2,147,483,647 characters. That should be enough to hold 5,000 characters with room to spare.
With the POST http method, a large amount of information can be sent without much trouble. You can upload much bigger files with the good old file upload forms.
String won't be the most efficient method, but I'll get the job done.
[ April 01, 2002: Message edited by: David Weitzman ]
reply
    Bookmark Topic Watch Topic
  • New Topic