Results 1 to 4 of 4

Thread: directories\folders in Java [RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member CaptainPinko's Avatar
    Join Date
    Jan 2001
    Location
    London, Ontario, Canada
    Posts
    332

    directories\folders in Java [RESOLVED]

    what class\package would i look at to learn how to open directories and create\delete and other such file maintenance stuff?
    Last edited by CaptainPinko; Dec 15th, 2001 at 07:59 AM.
    "There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein

    If you are programming in Java use www.NetBeans.org

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    java.io.File

    similar to FSO in VB

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Yes java.io.File; it's a pretty easy class to work with.
    I find myself always having to use a method from that class.

    There are three constructors:

    public File(String pathname);
    public File(String parent, String child);
    public File(File parent, String child);

    And a host of methods. Here are the ones i use the most.

    public boolean isFile();
    public String getName();
    public String getPath();
    public boolean createNewFile();
    public boolean delete();
    public boolean deleteOnExit();
    public long length();
    public boolean mkdir();
    public boolean mkdirs();
    public boolean renameTo(File dest);
    public File[] listFiles();
    public File[] listFiles(FilenameFilter filter);
    public File[] listFiles(java.io.FileFilter filter);
    public String[] list();
    public String[] list(FilenameFilter filter);

  4. #4
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Oh and here are two more that i use alot.

    public static File createTempFile(String prefix, String suffix);
    public static File createTempFile(String prefix, String suffix File directory);

    These methods usually come in handy when i need a temporary place to store data that i might need at a later time in my program. Use deleteOnExit() to request that the files be deleted when the Java VM exits normally.

Posting Permissions

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



Click Here to Expand Forum to Full Width