J2ME : parseInt is slow, faster ways to load data from text files ?

S

Sam Iam

On my J2ME phone I've found that parsing a few hundred comma seperated
numeric values will take up to five seconds.

I think it's because parseInt is slow.

Is there some other faster way to load up a bunch of values into
arrays of ints ?

- Sam.
 
R

Roedy Green

Is there some other faster way to load up a bunch of values into
arrays of ints ?

You might try my http://mindprod.com/products.html#CSV class to read
the csv file.

If you want it really fast, convert the data to binary and read it
with DataInputStream or LEDataInputStream

See http://mindprod.com/jgloss/ledatastream.html

Try bumping up the buffer size.
see http://mindprod.com/jgloss/fileio.html


Profile to see where the bottleneck REALLY is.

http://mindprod.com/jgloss/profiler.html
 
D

Darryl L. Pierce

Sam said:
On my J2ME phone I've found that parsing a few hundred comma seperated
numeric values will take up to five seconds.

I think it's because parseInt is slow.

Is there some other faster way to load up a bunch of values into
arrays of ints ?

If you have control of the data source, why not just write the data using a
DataOutputStream? Then you could read the data in using a DataInputStream.
 
S

Sam Iam

On my J2ME phone I've found that parsing a few hundred comma seperated
numeric values will take up to five seconds.

I think it's because parseInt is slow.

Is there some other faster way to load up a bunch of values into
arrays of ints ?

- Sam.

Thanks to Roedy & Darryl for their suggestion of switching to binary &
using DataInputStream.

I'm able to load numbers from my data file 10X faster now.

- Sam.
 
Joined
Jul 19, 2006
Messages
1
Reaction score
0
hi,
i am doing one j2me application, that needs to convert the text format into binary format,
please advise me how to do that?
thanks & regards,
satdmail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top