Java create a file/directory

Creating a file or directory in Java is very simple. You can specificity the file/directory path and then invoke mkdir() and createNewFile() methods. The following code example shows how to create a file and a directory.

import java.io.File;
public class Maker {
    public static void main(String[] args){
        try{
            File dir = new File("dir3");
            dir.mkdir();
            File file = new File(dir,"file3");
            file.createNewFile();
        }catch(Exception x){
        }
    }
}
Category >> Basics  
If you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:
<pre><code> 
String foo = "bar";
</code></pre>