Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jun 2006

    FileConnection/InputStream reading problem


    I am facing a problem with reading in data from a file using FileConnection.

    Cannot seem to read in any data from a file exceeding a certain file size.

    Below is a sample extract from my code which gives the problem:

    InputStream in=null;
    ByteArrayOutputStream bStrm=null;
    FileConnection fc = null;

    byte[] byteArray=null;
    byte[] raw = null;

    fc = (FileConnection) Connector.open("file://"+sfile.getPath()+

    in = fc.openInputStream();
    int noOfBytesRead=1;

    for(int i=1; i<=numChunks; i++){

    bStrm = new ByteArrayOutputStream();
    noOfBytesRead = 1;

    while(noOfBytesRead != -1) {
    byteArray = new byte[1];
    // System.out.println("in is null");
    // System.out.println("byteArray is null");
    noOfBytesRead = in.read(byteArray);

    if (noOfBytesRead != -1) {
    //System.out.println("byte stream write");

    raw = bStrm.toByteArray();

    catch(Exception e){

    The code above gives a NullPointerException at the line: in.read(byteArray) when I open the InputStream of a file of size 16MB. But for a file that is 14MB in size below, there is no problem. Uncommenting the println statements reveal that InputStream in is not null.

    I have varied the size of byteArray from 1 to 512 to 32K but it still fails.

    Can anyone help? Thanks a lot.

  2. #2
    Registered User
    Join Date
    Jun 2006

    Re: FileConnection/InputStream reading problem

    oops... sorry forgot to mention that i have been testing on an S60 Nokia emulator. Hope this additional detail helps.

Similar Threads

  1. CMsvSession Problem, Cannot access Inbox for reading SMS
    By peter0815neu in forum General Messaging
    Replies: 0
    Last Post: 2006-04-24, 15:00
  2. Problem while reading file on c: on 6630.
    By pankaj_hotwani in forum Mobile Java General
    Replies: 1
    Last Post: 2005-09-30, 13:09
  3. Problem with reading phone book details in noka 6210
    By master131181 in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2004-05-02, 14:54
  4. Problem reading txt-files from the net
    By Elwoodini in forum Mobile Java General
    Replies: 2
    Last Post: 2003-04-07, 03:04
  5. Problem about Reading Chinese Text file?
    By goeast in forum Mobile Java General
    Replies: 0
    Last Post: 2002-09-18, 03:25

Posting Permissions

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