how to write into a text file in j2me

Discussion in 'Java' started by rajesh, Feb 17, 2006.

  1. rajesh

    rajesh Guest

    Hi every one,

    I am doing a project in j2me and in that i need to add and modify my
    text file,
    which is grouped in the jar.

    As i know, by using class.getResourceAsStream(filename) this method we
    can read that file.

    but i want to write into that textfile.
    this iam not getting.
    plz any body help me.
    rajesh, Feb 17, 2006
    #1
    1. Advertising

  2. rajesh wrote:

    > I am doing a project in j2me and in that i need to add and modify my
    > text file,
    > which is grouped in the jar.


    No, you cannot modify the contents of the JAR file once it's installed onto
    a handset.

    > As i know, by using class.getResourceAsStream(filename) this method we
    > can read that file.
    >
    > but i want to write into that textfile.


    You can't. You can only write to a record store.

    --
    Darryl L. Pierce <>
    Homepage: http://mcpierce.multiply.com/
    "McVeigh's lawyer got him the death penalty, which, quite frankly,
    I could have done." - Jon Stewart
    *** Free account sponsored by SecureIX.com ***
    *** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***
    Darryl L. Pierce, Feb 17, 2006
    #2
    1. Advertising

  3. rajesh

    JScoobyCed Guest

    rajesh wrote:
    > Hi every one,
    >
    > I am doing a project in j2me and in that i need to add and modify my
    > text file,
    > which is grouped in the jar.
    >
    > As i know, by using class.getResourceAsStream(filename) this method we
    > can read that file.
    >
    > but i want to write into that textfile.
    > this iam not getting.
    > plz any body help me.
    >


    The only way one can write to the mobile File System in J2ME is to use
    (if supported) the JSR-75: FileConnection and PIM API.
    Additionaly, you can't modify a text file on the mobile if it is in the
    JAR running your application.

    --
    JSC
    JScoobyCed, Feb 20, 2006
    #3
  4. rajesh

    abbasvlb

    Joined:
    Jan 7, 2009
    Messages:
    2
    i it possible to write a content in text file that is present out side of the jar using J2me..

    i am having a jar file and text file.. from jar i want to write a code to add a content in text file..

    is it possible???
    abbasvlb, Jan 7, 2009
    #4
  5. rajesh

    hawknz

    Joined:
    Feb 12, 2010
    Messages:
    1
    resolved???

    Have you found a solution yet?
    hawknz, Feb 12, 2010
    #5
  6. rajesh

    Nilesh.ptl

    Joined:
    Feb 20, 2010
    Messages:
    1
    Yes it possible..

    Yes it is possible to Read/Write file in Mobile, But need to use Spelical API that are generally restricted by all mobile device. We need develop it as trusted application. I have develop it in NetBean 6.5 and with Emulator it Work Perfect But Mobile device show me ‘ Application Not Authorized to access the restricted API ’

    This is my Status with IO operation IF any ONE has idea Please HELP ME…

    My Code :
    Just import import javax.microedition.io.file.FileConnection;
    And try below code

    try
    {
    FileConnection fconn = (FileConnection)Connector.open("file:///c:/masterlist.txt", Connector.READ_WRITE);
    if (!fconn.exists())
    {
    fconn.create(); }
    else
    { /*Do As Like*/ }
    }
    catch (IOException ioe)
    {
    System.out.println("IOException: " + ioe.getMessage());
    }
    Nilesh.ptl, Feb 20, 2010
    #6
  7. rajesh

    sj123

    Joined:
    Jun 1, 2011
    Messages:
    1
    file access

    hi i m using netbeans.
    In jar file when i view the contents it gives
    hello/res.txt

    And when i try to open the contents of file using
    InputStream is = getClass().getResourceAsStream("/hello/route.txt");
    Its throwin exception

    why?
    sj123, Jun 1, 2011
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. robin
    Replies:
    0
    Views:
    838
    robin
    Jul 20, 2003
  2. Boldra
    Replies:
    0
    Views:
    1,259
    Boldra
    Dec 3, 2003
  3. Markus
    Replies:
    4
    Views:
    1,766
    Darryl Pierce
    Feb 12, 2005
  4. nishadixit
    Replies:
    5
    Views:
    1,229
    Joe Discar
    Jun 1, 2005
  5. Replies:
    5
    Views:
    242
Loading...

Share This Page