×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    50

    Unhappy Reading files with j2me

    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

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: Reading files with j2me

    Hi chia_84,

    try posting your code, so It'll be possible to find out possible improvements.

    Pit

  3. #3
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    50

    Re: Reading files with j2me

    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

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: Reading files with j2me

    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

  5. #5
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Reading files with j2me

    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

  6. #6
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Hamburg, Germany
    Posts
    283

    Wink Re: Reading files with j2me

    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

Similar Threads

  1. mixing two midi files using j2me
    By beenicravi in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2008-08-07, 09:43
  2. Mixing of two mp3 files using j2me......
    By beenicravi in forum Mobile Java Media (Graphics & Sounds)
    Replies: 18
    Last Post: 2008-07-24, 23:26
  3. Reading files efficiently from "E" drive
    By gbtw in forum Symbian
    Replies: 10
    Last Post: 2007-09-03, 04:54
  4. Reading and writting with buffers in J2ME
    By magnetic in forum Mobile Java General
    Replies: 5
    Last Post: 2007-01-11, 15:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×