Results 1 to 4 of 4
  1. #1
    sina is offline Member
    Join Date
    Mar 2008
    Posts
    1
    Rep Power
    0

    Unhappy a simple code (cldc or midp) to write a text file ouside of the application package

    hello all friends,
    assume my midlet is located in c:/myprojects/mymidlet.jar. now i want to add one or more lines of code so it will creat a text file in d:/somefolder/text.txt.
    I just dont know how should I do this as it requires playing with absolute paths. please write me the required statments.
    thank a million

  2. #2
    sk_shadul is offline Member
    Join Date
    Mar 2008
    Posts
    5
    Rep Power
    0

    Default

    hi,

    If you want to create a text file, create an object of a file which should have an argument of full path where you want to create.

    import java.io.File.*;
    File newFile= new File("FullPath");
    // operations

    Hope, this information will help you.

    Regards,
    sk_shadul

  3. #3
    aibtus's Avatar
    aibtus is offline Member
    Join Date
    Mar 2008
    Location
    Randburg, South Africa
    Posts
    9
    Rep Power
    0

    Default

    I hope you have a good reason to do so. Most midlets will be used on mobile phones and not the desktop environment, where they are developed and tested on, thus rendering your absolute path useless on the phones.

    I would think you want to write the text file to some location on the mobile device. It's just my point of view

  4. #4
    Moon123 is offline Member
    Join Date
    Dec 2008
    Posts
    1
    Rep Power
    0

    Default

    Hi ya.
    Creating files when testing your code on a PC is different from when you do it on your phone. On your PC, depending on what you are using (Netbeans, WTK, etc)there is a specific folder that you could create files in to test your code and as far as I know that's the only folder you can use. I might be wrong though.

    On the phone however, it is a different story. Depending on your phone, you could write wherever you want. I'm using Nokia N95 for testing so I can write
    to "file:///E:/Documents/" which is the Documents folder on my SD card (called E on Noika N95).

    Hope this is of some help to you.



    Quote Originally Posted by sina View Post
    hello all friends,
    assume my midlet is located in c:/myprojects/mymidlet.jar. now i want to add one or more lines of code so it will creat a text file in d:/somefolder/text.txt.
    I just dont know how should I do this as it requires playing with absolute paths. please write me the required statments.
    thank a million

Similar Threads

  1. What are you using to write your code?
    By CaptainMorgan in forum New To Java
    Replies: 991
    Last Post: 08-22-2014, 06:35 PM
  2. Replies: 5
    Last Post: 06-07-2014, 05:39 PM
  3. how do i write to a text file from an arraylist?
    By otoro_java in forum New To Java
    Replies: 3
    Last Post: 01-30-2008, 06:53 AM
  4. simple code
    By elizabeth in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 06:49 PM

Posting Permissions

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