Hi friend's today I'm here with simple code to create a new folder using java. Without wasting any time let's get into the process.
1. Open notepad copy and paste the below code and save it with name java1.java in any location.
2. Goto the notepad location. Press shift button + right click mouse and select open command window here.
3. If you already set the java path to your PC skip this step. Else type java -version in cmd prompt and hit enter.
a. Make note of the version type.
b. Goto C:\Program Files\Java and open your version folder in that bin and press F6 then copy the path which looks like C:\Program Files\Java\jdk1.8.0_72\bin
c. Open new notepad type set path="paste here" now copy everything and paste it in cmd prompt and hit enter.
d. Now path was set.
4. Now compile file by using cmd javac java1.java
5. Now execute the program by using cmd java Folderfile
6. Now you can see a new folder created in the location.
1. Open notepad copy and paste the below code and save it with name java1.java in any location.
2. Goto the notepad location. Press shift button + right click mouse and select open command window here.
3. If you already set the java path to your PC skip this step. Else type java -version in cmd prompt and hit enter.
a. Make note of the version type.
b. Goto C:\Program Files\Java and open your version folder in that bin and press F6 then copy the path which looks like C:\Program Files\Java\jdk1.8.0_72\bin
c. Open new notepad type set path="paste here" now copy everything and paste it in cmd prompt and hit enter.
d. Now path was set.
4. Now compile file by using cmd javac java1.java
5. Now execute the program by using cmd java Folderfile
6. Now you can see a new folder created in the location.
Program:
import java.io.File;
class Folderfile
{
public static void main(String args[])
{
File f = new File("Folder1");
if(f.mkdir())
{
System.out.println("Folder Creaded...");
}
else
{
System.out.println("Can't create Folder...");
}
}
}
No comments:
Post a Comment