I would like to know how you can speed up reading a file with an application j2me, because the application takes a relatively long time when they must read a file txt / xml
chia_84
I would like to know how you can speed up reading a file with an application j2me, because the application takes a relatively long time when they must read a file txt / xml
chia_84
Hi chia_84,
try posting your code, so It'll be possible to find out possible improvements.
Pit
My application reads a file xml .. when I install the file .jar on the device and when the application must read this file takes a few seconds before viewing the result.
I just wanted to see if there's a way to reduce this time .. because if the application is blocked
chia_84
Time spent reading a file highly depends on various points, as:
* file size
* reading method (e.g.: byte by byte, by chunks)
* JVM performance
Generally speaking, few seconds are not that much when reading a file in Java ME. If your application totally blocks, then it's likely you're not correctly using Threads to handle this long-running operation. For detailed infos about this topic, check these links:
http://developers.sun.com/mobility/m...les/threading/
http://developers.sun.com/mobility/m...es/threading2/
Hope it helps,
Pit
Put u r file in Resource(res) folder and read it via this
InputStream is = getClass().getResourceAsStream(file name+".xml");
try
{
StringBuffer sb = new StringBuffer();
int chr, i = 0;
// Read until the end of the stream
while ((chr = is.read()) != -1)
sb.append((char) chr);
strData=sb.toString();
// System.out.println("MenuCanvas.getText()"+strData);
}
catch (Exception e)
{
System.out.println("Unable to create stream");
}
Anshu Chauhan
J2me Developer
You can speed up XML reading if you don't use XML ;-)
In an application, I have made the reading about 3 times faster by using a special format.
Regards
Meier