Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User Vitalik100's Avatar
    Join Date
    Oct 2009
    Location
    Russia, Yaroslavl region
    Posts
    6
    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 batora's Avatar
    Join Date
    Sep 2009
    Posts
    12
    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
    Registered User grahamhughes's Avatar
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,394
    That's right. You might find this document helpful.

    Graham.

  4. #4
    Registered User Vitalik100's Avatar
    Join Date
    Oct 2009
    Location
    Russia, Yaroslavl region
    Posts
    6
    Thanks peoples! will be trying

  5. #5
    Nokia Developer Champion jitu_goldie's Avatar
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330
    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. [moved] Theme Studio Error
    By TalJ in forum Themes/Carbide.ui
    Replies: 2
    Last Post: 2009-09-06, 03:39
  2. Database File creating in Run time...
    By keerthi.ck06 in forum Symbian C++
    Replies: 18
    Last Post: 2009-07-13, 11:15
  3. Regarding BMCONV
    By sanah007 in forum Symbian C++
    Replies: 2
    Last Post: 2009-05-26, 12:47
  4. S60 theme questions
    By Nokian_Spb in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2006-08-17, 06:11
  5. 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
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved