Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2008

    URGENT: Reading File from memory card problem

    I am trying to read the mp3 file from memory card using FileConnection APIs in J2ME. When i use read() call, it throws "Native error" and "Operation in Progress" Exception. Can someone suggest what the code needs to be as the code is in line?

    FileConnection fc = (FileConnection)Connector.open(file_path, Connector.READ);

    if (!fc.exists()){
    Log.out("File does not exit");
    throw new IOException("File Does not exist");
    InputStream is = fc.openInputStream();

    fileSize = fc.fileSize();
    hs.setHeader(HeaderSet.NAME, media.getNameWithExt());
    hs.setHeader(HeaderSet.TYPE, "audio/mp3");
    hs.setHeader(HeaderSet.LENGTH, new Long(fileSize));
    Operation putOperation = cs.put(hs);
    OutputStream outputStream = putOperation.openOutputStream();

    Log.out("The size of the file is :" + fileSize);

    while(readLength < fileSize){
    if(fileSize-readLength < 1024)
    length = (int)fileSize - readLength;
    length = 1024;
    Log.out("The size of the length is:"+ length);
    in = new byte[(int)length];
    Log.out("array created successfully");

    int bytesRead=0;
    int current=0;
    bytesRead = is.read(in, current, in.length-current-1);

    if (bytesRead > 0)
    current += bytesRead;
    }while (bytesRead > 0);

    outputStream.write(in, 0, current);
    readLength += length;

    catch(Exception e){

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    USA, CA

    Re: URGENT: Reading File from memory card problem

    Which device are you talking about?
    Do you have some other applications running on the background and reading the file?
    So you do not get any security exceptions, right?


Similar Threads

  1. Replies: 15
    Last Post: 2007-10-24, 13:47
  2. Error with makesis.exe and creating the .pkg file
    By gramya87 in forum Symbian Tools & SDKs
    Replies: 7
    Last Post: 2007-10-10, 13:53
  3. Phone not reading memory card on 6630
    By crazymofo in forum General Development Questions
    Replies: 3
    Last Post: 2007-10-08, 16:27
  4. Problem with reading a file........
    By rafeeqpv in forum Symbian
    Replies: 0
    Last Post: 2005-11-15, 14:09
  5. Replies: 8
    Last Post: 2004-06-16, 08:38

Posting Permissions

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