Difference between revisions of "Get the current directory"

From CodeCodex

 
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
==Implementations==
 
==Implementations==
 +
===Common Lisp===
 +
<pre>
 +
(user-homedir-pathname)
 +
</pre>
 
===Java===
 
===Java===
 
The working directory is the location in the file system from where the java command was invoked.
 
The working directory is the location in the file system from where the java command was invoked.
Line 8: 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
==Implementations==
+
 
 
===Java===
 
===Java===
 
<pre>
 
<pre>
Line 25: Line 29:
 
</pre>
 
</pre>
 
* Original Source: [http://javaalmanac.com/egs/java.io/pkg.html?l=rel#Files The Java Developers Almanac 1.4]
 
* Original Source: [http://javaalmanac.com/egs/java.io/pkg.html?l=rel#Files The Java Developers Almanac 1.4]
 +
 +
=== Tcl ===
 +
<pre class="tcl">
 +
set dir [pwd]
 +
</pre>
 +
 +
[[Category:Common Lisp]]
 
[[Category:Java]]
 
[[Category:Java]]
 +
[[Category:Tcl]]
 
[[Category:I/O]]
 
[[Category:I/O]]

Latest revision as of 20:22, 21 February 2011

Implementations[edit]

Common Lisp[edit]

(user-homedir-pathname)

Java[edit]

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

Java[edit]

    // 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
    }

Tcl[edit]

set dir [pwd]