Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
ashokbb_narra
Posts: 13
Registered: ‎02-26-2013
My Device: blackberry curve 8520

How to Read from each line Input Stream and to Vector in BB?

Hi i have some data in InputStream . now i want to read line by line and add to vector.

 

I am using the followng code

InputStream stream = new ByteArrayInputStream(emlBody.getBytes());
Vector listAll = new Vector();
if(stream != null)
{
try {

LineReader lineReader = new LineReader(stream);
// byte[] line = lineReader.readLine();
// String lineStr=new String(line);
String lineStr;
while ((lineStr = new String(lineReader.readLine())) != null)
{
listAll.addElement(lineStr);
}

} catch (Exception e) {
// TODO: handle exception
}



}

but if the data is more it is taking more time time to read .so how to improve performance?.

 

if the data is in 1000 lines ,it is taking more time. how to solve this problem?

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to Read from each line Input Stream and to Vector in BB?

Can you confirm that the slow down is actually in this code?. 

 

One simple way to do this would be to get the current time (System.currentTimeMillis())

just before you start this process, then subtract that from the time when you have been through the processing of splitting this up.

 

The other thing to watch out for is memory issues.  While you are doing this processing do you see the hourglass symbol appearing on the screen?

 

Anyway, before we focus our attention on this specific bit of code, I suggest we confirm that it is in fact this bit of code causing the slowdown.  I doubt that it is this code.