wood burning stoves*
The moose likes Java in General and the fly likes How to intialize large String content in string literal? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to intialize large String content in string literal?" Watch "How to intialize large String content in string literal?" New topic
Author

How to intialize large String content in string literal?

santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
Hi,

I had a large string content which consists of more than 10 thousand words, hence each time i called the respective java the string gets initialized,so it hits performance,is there any way to improve performance?


Creativity is nothing but Breaking Rules
R. Jain
Ranch Hand

Joined: Aug 11, 2012
Posts: 370
    
    1

santhosh.R gowda wrote:Hi,
I had a large string content which consists of more than 10 thousand words, hence each time i called the respective java the string gets initialized,so it hits performance,is there any way to improve performance?


Is that string fixed all over your application or you are supposed to modify it??
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7549
    
  18

santhosh.R gowda wrote:I had a large string content which consists of more than 10 thousand words

The term "large string content" covers a multitude of sins. Where does it come from? A file? A database? If a file, is that file arranged in lines? All these things will have an effect on how you proceed.

Second: Don't obsess about efficiency, either for space or speed. Get it right. Tweaks for efficiency can always come later, and 10,000 words is 150K or so - peanuts for most modern machines. If it were 10 million words, you might have cause for worry, but even then my advice would be the same: get it right first.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38016
    
  22
santhosh.R gowda wrote: . . . each time i called the respective java the string gets initialized, . . .
I don’t understand that bit. Do you mean the String is initialised every time you start the JVM? Does it actually have more than one initialisation per execution?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to intialize large String content in string literal?
 
Similar Threads
Performance Issue wth writing "text/javascript" content into HttpServletResponse
How to send bulk data using Javamail API
read from a file into a string
Auto Resizing problem with JFrame
Reading large txt files