Difference between revisions of "Get the current directory"

From CodeCodex

m (Java)
(Implementations)
Line 12: Line 12:
  
 
www.codecodex.com/wiki/index.php?title=Creating a Directory&action=edit
 
www.codecodex.com/wiki/index.php?title=Creating a Directory&action=edit
 +
 +
=== Tcl ===
 +
<pre class="tcl">
 +
set dir [pwd]
 +
</pre>
 +
 +
[[Category:Tcl]]
 +
 
==Implementations==
 
==Implementations==
 
===Java===
 
===Java===

Revision as of 20:20, 21 February 2011

Implementations

Common Lisp

(user-homedir-pathname)

Java

The working directory is the location in the file system from where the java command was invoked.

String curDir = System.getProperty("user.dir");

www.codecodex.com/wiki/index.php?title=Creating a Directory&action=edit

Tcl

set dir [pwd]

Implementations

Java

    // Create a directory; all ancestor directories must exist
    boolean success = (new File("directoryName")).mkdir();
    if (!success) {
        // Directory creation failed
    }
    
    // Create a directory; all non-existent ancestor directories are
    // automatically created
    success = (new File("directoryName")).mkdirs();
    if (!success) {
        // Directory creation failed
    }