Difference between revisions of "Create a directory"

From CodeCodex

 
Line 16: Line 16:
 
</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]
 +
===OCaml===
 +
<pre>
 +
# Unix.mkdir "foo" 666;;
 +
- : unit = ()
 +
</pre>
 
[[Category:Java]]
 
[[Category:Java]]
 
[[Category:I/O]]
 
[[Category:I/O]]

Revision as of 17:17, 2 August 2006

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
    }

OCaml

# Unix.mkdir "foo" 666;;
- : unit = ()