×

Discussion Board

Results 1 to 6 of 6

Thread: File connection

  1. #1
    Regular Contributor
    Join Date
    Jul 2010
    Posts
    178

    File connection

    Hi
    I was created xml file using kxml parser codng in the emulator Location ie(C:\Nokia\Devices\S40_6th_Edition_SDK\bin\Storage\6260000\C\predefgallery\predefphotos\my.xml)
    we can't created a file in other location because it so Access Denied Error
    i want to make use of the file(above said) in the same program to parse
    Here is the problem for parsing the file should be with in the src folder then only it is parsed.
    place the file on src folder and make use of ithe following getclass().getResourceAsStream("/my.xml")
    it working fine.for that manually move that file
    i need program to move the file
    i do not know what to do?

  2. #2
    Registered User
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868

    Re: File connection

    Hi senthil_25 ,

    For that you need to use the FileConnection APIS . In that you need to navigate through the required location and read the file data . for more help on this read forum nokia wiki section about JSR-75 API

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: File connection

    Quote Originally Posted by senthil_25 View Post
    Hi
    I was created xml file using kxml parser codng in the emulator Location ie(C:\Nokia\Devices\S40_6th_Edition_SDK\bin\Storage\6260000\C\predefgallery\predefphotos\my.xml)
    we can't created a file in other location because it so Access Denied Error
    i want to make use of the file(above said) in the same program to parse
    Here is the problem for parsing the file should be with in the src folder then only it is parsed.
    place the file on src folder and make use of ithe following getclass().getResourceAsStream("/my.xml")
    it working fine.for that manually move that file
    i need program to move the file
    i do not know what to do?
    Using FCA JSR 75 - File Connection API you can read / write from/to - file system on the device which is public and accessible to your app - You can write in src folder.
    For parsing this file, fetch the stream by creating the file connection and pass it to the parser. If you are not able to do it using KXML try with parser from JSR 172, now its available on most of the devices in the market.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  4. #4
    Regular Contributor
    Join Date
    Jul 2010
    Posts
    178

    Re: File connection

    Hi

    Thanks for quick reply .
    I have created xml file in the following location String url = System.getProperty("fileconn.dir.photos") + "home.xml";
    And try to parse it using KXML parse
    String url = System.getProperty("fileconn.dir.photos") + "home.xml";
    InputStream in1 = getClass().getResourceAsStream(url);

    But it still show Error:java.lang.NullPointerException
    Is NetBeans only fetch a file from Src folder?If so then how to use System.getProperty() to this src folder
    Otherwise i have to go with bhanuchandar.k idea.
    Please guide me.

  5. #5
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: File connection

    InputStream in1 = getClass().getResourceAsStream(url);
    Instead of above use - FileConnection of JSR75 to open a connection and then InputStream on it, pass it to the parser.

    try

    Code:
    FileConnection fconn = (FileConnection)Connector.open(url, Connector.READ);
                InputStream in1 = fconn.openInputStream();
    // Now pass this in1 to the parser.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  6. #6
    Regular Contributor
    Join Date
    Jul 2010
    Posts
    178

    Re: File connection

    Hi im2amit
    Its working Fine.
    Thanks for your quick and correct reply.

Similar Threads

  1. How to encounter end of File using File Connection API's
    By pvumesh in forum Mobile Java General
    Replies: 8
    Last Post: 2010-01-27, 11:04
  2. can we cast file connection to file
    By ansh.chauhan in forum Mobile Java General
    Replies: 2
    Last Post: 2008-11-27, 05:06
  3. file connection
    By jebeng in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2008-03-03, 06:51
  4. File System(File Connection API)
    By amalshah73 in forum Mobile Java General
    Replies: 1
    Last Post: 2007-08-26, 02:41
  5. File connection.
    By balagopalks in forum Mobile Java General
    Replies: 4
    Last Post: 2004-12-15, 05:06

Posting Permissions

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