×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Registered User
    Join Date
    Feb 2007
    Posts
    10

    directory creation

    hi.........

    i want to create a directory in mobile using j2me. I don't know the exect way to do it. any body pls give me the code how to create a directory.

  2. #2
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: directory creation

    Have a look at API docs.

    mkdir
    public void mkdir()
    throws java.io.IOException
    Creates a directory corresponding to the directory string provided in the Connector.open() method. The directory is created immediately on the actual file system upon invocation of this method. Directories in the specified path are not recursively created and must be explicitly created before subdirectories can be created.

    Throws:
    java.lang.SecurityException - if the security of the application does not have write access to the directory.
    IllegalModeException - if the application does have write access to the directory but has opened the connection in Connector.READ mode.
    java.io.IOException - if invoked on an existing directory or on any file (create() is used to create files), the target file sytem is not accessible, or an unspecified error occurs preventing creation of the directory.
    ConnectionClosedException - if the connection is closed.
    Regards
    Gopal

    __________________
    MobiQuil.com
    An initiative by Developers for Developers.
    http://www.mobiquil.com - Alpha - Launched.

  3. #3
    Registered User
    Join Date
    Feb 2007
    Posts
    10

    Re: directory creation

    hi..........

    Now the directory is created but i m not able to display it with the list of Directories.....either on memory card or on C:\ drive......


    if you can help me on this pls....




    susha

  4. #4
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: directory creation

    public java.util.Enumeration list()
    throws java.io.IOException
    Gets a list of all visible files and directories contained in a directory. The directory is the connection's target as specified in Connector.open().

    Returns:
    An Enumeration of strings, denoting the files and directories in the directory. The string returned contain only the file or directory name and does not contain any path prefix (to get a complete path for each file or directory, prepend getPath()). Directories are denoted with a trailing slash "/" in their returned name. The Enumeration has zero length if the directory is empty. Any hidden files and directories in the directory are not included in the returned list. Any current directory indication (".") and any parent directory indication ("..") is not included in the list of files and directories returned.
    Throws:
    java.io.IOException - if invoked on a file, the directory does not exist, the directory is not accessible, or an I/O error occurs.
    ConnectionClosedException - if the connection is closed.
    java.lang.SecurityException - if the security of the application does not have read access for the directory.
    IllegalModeException - if the application does have read access to the directory but has opened the connection in Connector.WRITE mode.
    public java.util.Enumeration list(java.lang.String filter, boolean includeHidden)
    throws java.io.IOException
    Gets a filtered list of files and directories contained in a directory. The directory is the connection's target as specified in Connector.open().

    Parameters:
    filter - String against which all files and directories are matched for retrieval. An asterisk ("*") can be used as a wildcard to represent 0 or more occurrences of any character.
    includeHidden - boolean indicating whether files marked as hidden should be included or not in the list of files and directories returned.
    Returns:
    An Enumeration of strings, denoting the files and directories in the directory matching the filter. Directories are denoted with a trailing slash "/" in their returned name. The Enumeration has zero length if the directory is empty or no files and/or directories are found matching the given filter. Any current directory indication (".") and any parent directory indication ("..") is not included in the list of files and directories returned.
    Throws:
    java.io.IOException - if invoked on a file, the directory does not exist, the directory is not accessible, or an I/O error occurs.
    ConnectionClosedException - if the connection is closed.
    java.lang.SecurityException - if the security of the application does not have read access for the directory.
    IllegalModeException - if the application does have read access to the connection's target but has opened the connection in Connector.WRITE mode.
    java.lang.NullPointerException - if filter is null.
    java.lang.IllegalArgumentException - if filter contains any path specification or is an invalid filename for the platform (e.g. contains characters invalid for a filename on the platform).
    Also have a look at listRoots()
    An online version of API docs is available here http://www.j2medev.com/api/fileconne...w-summary.html

    Regards
    Gopal

    __________________
    MobiQuil.com
    An initiative by Developers for Developers.
    http://www.mobiquil.com - Alpha - Launched.

  5. #5
    Registered User
    Join Date
    Jan 2007
    Posts
    18

    Re: directory creation

    Hi,
    I have written an application for file access.I able to write & read from file but how can I append text to a file ?
    My code is like that for connection:
    connection=(OutputConnection)Connector.open("file:///root1/myfile9.txt;append=true", Connector.WRITE);
    java.io.IOException:
    at com.sun.midp.io.j2me.file.Protocol.openOutputStream(+47)
    at com.sun.midp.io.j2me.file.Protocol.openOutputStream(+5)
    at File_Append$FileForm.run(+35)

    But if I omit this append=true; portion then Its working fine & data is written to the file.
    Can anybody tell me how can I append data to a file ,It is so urgent!
    Thanks in advance.

  6. #6
    Registered User
    Join Date
    Feb 2007
    Posts
    10

    Re: directory creation

    hi...

    I have created a directory, i created it in root1(using j2me toolkit) .
    again i changed the path(/SDCard/name)and instald te application in to mobile(N72).But now it is not working.It shows Error(Exception). pls tell me the correct way to work this application in mobile.. Need any more change in the path?


    Thanks in advance.
    susha

  7. #7
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: directory creation

    I suggest you to go through the Blog
    "FileConnection - Introduction to beginners"
    https://blogs.forum.nokia.com/view_entry.html?id=131

    Also please dont forget to go through "MIDP: FileConnection API Developer's Guide (with Example) v2.0"
    http://www.forum.nokia.com/info/sw.n..._0_en.zip.html

    Hope this shoot out all your problems!

    Regards
    Gopal

    __________________
    MobiQuil.com
    An initiative by Developers for Developers.
    http://www.mobiquil.com - Alpha - Launched.

  8. #8
    Registered User
    Join Date
    Feb 2007
    Posts
    10

    Re: directory creation

    hi,

    i checked these link,in that they specified the path (/SDCard).but i tried it in my mobile.but it shows error again.Is there need any more changes in code?

    regards
    susha

  9. #9
    Registered User
    Join Date
    Mar 2007
    Posts
    2

    Re: directory creation

    Hello gopal,
    i m using the following codes to create a directory in images folder ..

    String initDir = System.getProperty("fileconn.dir.photos")+"new";
    //String path=System.getProperty("Fileconn.dir.photos")+"new";
    fmMain.append(initDir);
    try {

    FileConnection fc=(FileConnection)Connector.open(initDir,Connector.WRITE);
    if(!fc.exists())
    {
    fc.mkdir();
    Alert alert1 = new Alert("dir CREATION Completed", "Data Written", null, null);
    alert1.setTimeout(Alert.FOREVER);
    fc.close();
    }
    but i will get a "SecurityException"
    so plz sugest any perticular mobile for that..to create ..i m also given the permission to to Fileconnection.read,Fileconnection.write ..but i get thye same error ....plz reply anyone

  10. #10
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: directory creation

    Hi arunoosy! Welcome to Nokia Discussion Boards!!

    Hope your phones does suupport JSR 75. Is your phone an operator branded one? Is your MIDlet signed?
    Please make sure that you allow the permission messages popping up.

    Regards
    Gopal

    __________________
    MobiQuil.com
    An initiative by Developers for Developers.
    http://www.mobiquil.com - Alpha - Launched.

  11. #11
    Registered User
    Join Date
    Feb 2007
    Posts
    10

    Re: directory creation

    Iam using the n72 mobile.I can reading the file,but i can't create the directory,it shows no permission.how to resolvr this permission error?

  12. #12
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: directory creation

    Quote Originally Posted by susha
    Iam using the n72 mobile.I can reading the file,but i can't create the directory,it shows no permission.how to resolvr this permission error?
    Try with canWrite()
    public boolean canWrite()
    Checks if the file or directory is writable. This method checks the attributes associated with a file or directory by the underlying file system. Some file systems may not support associating a write attribute with a file, in which case this method returns true.

    Returns:
    true if the connection's target exists, is accessible, and is writable, otherwise false.
    Throws:
    java.lang.SecurityException - if the security of the application does not have read access for the connection's target.
    IllegalModeException - if the application does have read access to the connection's target but has opened the connection in Connector.WRITE mode.
    ConnectionClosedException - if the connection is closed.
    Regards
    Gopal

    __________________
    MobiQuil.com
    An initiative by Developers for Developers.
    http://www.mobiquil.com - Alpha - Launched.

  13. #13
    Registered User
    Join Date
    Feb 2007
    Posts
    10

    Re: directory creation

    hiiiiiiiiiii...........

    pls tell me anyone have created a directory in mobile.pls tell me in which nokia set.i want these details urgent...please help me.
    is it possible in N72.


    regards
    susha

  14. #14
    Regular Contributor
    Join Date
    Aug 2006
    Location
    Rawalpindi, Pakistan
    Posts
    486

    Re: directory creation

    i have created a directory in nokia 6680 i dont know about N72
    Regards
    Nouman

  15. #15
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: directory creation

    Quote Originally Posted by susha
    pls tell me anyone have created a directory in mobile.pls tell me in which nokia set.i want these details urgent...please help me.
    is it possible in N72.
    I tried the following code on my friends N93 and it worked fine.
    fc = (FileConnection)Connector.open("file:///c:/Nokia/Sounds/TestDIR/");
    if (!fc.exists()) {
    fc.mkdir();
    }
    I have never tried with N72, hopefully, this will work fine with N72 as well.

    Regards
    Gopal

    __________________
    MobiQuil.com
    An initiative by Developers for Developers.
    http://www.mobiquil.com - Alpha - Launched.

Similar Threads

  1. Auton Synch directory contents over USB ?.
    By prosperoiom in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-08-13, 15:36
  2. Fedora Core 1
    By jarmo2 in forum Multimodecards
    Replies: 2
    Last Post: 2004-04-20, 18:56
  3. dll and lib problem
    By dalore in forum Symbian
    Replies: 3
    Last Post: 2004-02-16, 13:08
  4. creating Directory
    By gaurav17281 in forum Symbian
    Replies: 2
    Last Post: 2003-10-15, 09:51
  5. How do I resolve a corrupt directory on 9210 ?
    By hellride in forum Symbian
    Replies: 1
    Last Post: 2002-06-12, 07:49

Posting Permissions

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