I am trying to load an entire file in memory as a string object.But after the application is over,my memory is not getting released back to garbage collector.I know reading the entire file in memory is bad,bu I have to send the data to another class,could anyone help me how to do this as just a stream instead of loading the entire code in memory,if not,could anyone say what is wrong with my present code
private String processFile(FileItemStream item) throws IOException{
InputStream is=null;
try{
is=item.openStream();
return IOUtils.toString(is, "UTF-8");
}
finally {
IOUtils.closeQuietly(is);
}
}
data=processFile(item)//method call
SomeClass(data);//passing the data string to this class