×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Oct 2009
    Location
    Russia, Yaroslavl region
    Posts
    6

    Long File opening time

    Hello, I wrote simple program that reading *.jpg file into byte array.
    But when i trying to open 400 kB jpg file it takes about 2 minutes.
    I am using NOKIA 6233. Is it normal time for opening such size files?
    But when you browsing jpg photos by internal tools it takes time not more than 2 second.
    How can i reduce opening time, is there any othere means in J2ME?
    Will be this time smaller if i will using C++ progrmming?
    My code:
    String s1;

    s1 = System.getProperty("fileconn.dir.memorycard")+"proba.jpg";
    FileConnection fc = (FileConnection)Connector.open(s1,Connector.READ);

    DataInputStream txtinStream = fc.openDataInputStream();

    ByteArrayOutputStream bStrm = new ByteArrayOutputStream();
    int ch;
    while ((ch = txtinStream.read()) != -1) bStrm.write(ch);
    DataArray = bStrm.toByteArray();

    stringItem2.setText(s1 + " "+java.lang.String.valueOf(DataArray.length));

    fc.close();

  2. #2
    Registered User
    Join Date
    Sep 2009
    Posts
    12

    Re: Long File opening time

    You should not read file byte by byte, I guess that's why it takes so long to load it.
    Try to read file in buffer with read(char[] cbuf, int off, int len) method.

  3. #3
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Long File opening time

    That's right. You might find this document helpful.

    Graham.

  4. #4
    Registered User
    Join Date
    Oct 2009
    Location
    Russia, Yaroslavl region
    Posts
    6

    Re: Long File opening time

    Thanks peoples! will be trying

  5. #5
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Long File opening time

    For better performance u have to read data in chunks. Instead of reading data byte by byte, read it in chunks.
    use inputsream.read(byte[],offset,length) for better performance..

    check and revert..
    thanks,
    jitu_goldie..

    KEEP TRYING..

Similar Threads

  1. Database File creating in Run time...
    By keerthi.ck06 in forum Symbian
    Replies: 18
    Last Post: 2009-07-13, 11:15
  2. Regarding BMCONV
    By sanah007 in forum Symbian
    Replies: 2
    Last Post: 2009-05-26, 12:47
  3. S60 theme questions
    By Nokian_Spb in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2006-08-17, 06:11
  4. PC Connectity with VB6
    By mkintanar in forum PC Suite API and PC Connectivity SDK
    Replies: 5
    Last Post: 2003-09-24, 04:18

Posting Permissions

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