Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create empty folder in java? [duplicate]

People also ask

How do I make a folder empty?

Just right-click on the folder, and select properties. Go to Customize and then click on the Change Icon button. After that, select the blank icon or the icon without any picture and click on OK. After doing this, you are finally going to be having a folder without any name nor any icon.

Can we create empty file in Java?

A new empty file with the required abstract path name can be created using the method java. io. File.

Can we create a folder in Java?

In Java, we can use the File object to create a new folder or directory. The File class of Java provide a way through which we can make or create a directory or folder. We use the mkdir() method of the File class to create a new folder.

Why is Java directory empty?

If the src folder is empty it means there is no java files in project, so you can't run that project.


Looks file you use the .mkdirs() method on a File object: http://www.roseindia.net/java/beginners/java-create-directory.shtml

// Create a directory; all non-existent ancestor directories are
// automatically created
success = (new File("../potentially/long/pathname/without/all/dirs")).mkdirs();
if (!success) {
    // Directory creation failed
}

You can create folder using the following Java code:

File dir = new File("nameoffolder");
dir.mkdir();

By executing above you will have folder 'nameoffolder' in current folder.