×

Discussion Board

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

    saving files using fileConnection API - not working

    FileConnection fc = (FileConnection)Connector.open("file:///E:/" + fileName + ".txt",Connector.READ_WRITE) ;

    if (!fc.exists())
    {
    fc.create(); // create the file if it doesn't exist
    }

    fc.setWritable(true) ;
    fc.setReadable(true) ;

    DataOutputStream dos = fc.openDataOutputStream() ;
    dos.writeUTF(value) ;
    dos.flush() ;
    dos.close() ;

    fc.close();

    // Adding File Name in RecordStore
    byte [] name = fileName.getBytes() ;
    rs.addRecord(name, 0, name.length) ;

    System.out.println("Saved File " + fileName) ;

    Sometimes it is saving files as normal readable files while at other times it is saving protected files which are unreadable and unmovable. Please tell how to solve this issue.

  2. #2
    Registered User
    Join Date
    Sep 2012
    Posts
    31

    Re: saving files using fileConnection API - not working

    Quote Originally Posted by skjsaurabh View Post
    FileConnection fc = (FileConnection)Connector.open("file:///E:/" + fileName + ".txt",Connector.READ_WRITE) ;

    if (!fc.exists())
    {
    fc.create(); // create the file if it doesn't exist
    }

    fc.setWritable(true) ;
    fc.setReadable(true) ;

    DataOutputStream dos = fc.openDataOutputStream() ;
    dos.writeUTF(value) ;
    dos.flush() ;
    dos.close() ;

    fc.close();

    // Adding File Name in RecordStore
    byte [] name = fileName.getBytes() ;
    rs.addRecord(name, 0, name.length) ;

    System.out.println("Saved File " + fileName) ;

    Sometimes it is saving files as normal readable files while at other times it is saving protected files which are unreadable and unmovable. Please tell how to solve this issue.
    http://www.developer.nokia.com/Commu...ile_in_Java_ME
    check this link
    also unless you add the setHidden property true there is no point that the file will be hidden as far as i know .
    Try out the code given in the code snippet . Also for your knowledge its always better to check whether you have permissions to write a file in hte
    given location . If you get the first location that has persmission to write a file you can use it . Also mention the device you are trying to test on
    so that it will be helpful for others to solve your issue
    Regards,
    Venkatesh

Similar Threads

  1. List of Bluetooth devices and saving it using FileConnection
    By eian@nokia in forum Mobile Java General
    Replies: 7
    Last Post: 2010-08-03, 11:09
  2. FileConnection not working on device
    By sandeepkumar03 in forum Mobile Java General
    Replies: 2
    Last Post: 2009-06-24, 05:51
  3. Problem saving an image using FileConnection
    By pmgf_14 in forum Mobile Java General
    Replies: 7
    Last Post: 2008-08-18, 23:41
  4. saving data using fileconnection API
    By lachee in forum Mobile Java General
    Replies: 6
    Last Post: 2007-07-16, 12:52

Posting Permissions

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