import java.io.*;
import java.util.*;
public class Folder{
Scanner scan=new Scanner(System.in);
String folderName;
public void input(){
try{
System.out.printf("Folder Name: ");
folderName=scan.nextLine();
}
catch(InputMismatchException e){
System.err.println("Error Occured!\n"+e.getMessage());
System.exit(0);
}
}
public void compute(){
String path=getDesktopPath();
File folder=new File(path+"\\"+folderName);
if(!folder.exists())
folder.mkdir();
else{
System.err.println("Folder Already Exists!");
System.exit(0);
}
if(folder.exists())
System.out.println("Folder Created!");
else
System.out.println("Folder not Created!");
}
public String getDesktopPath(){
String path=System.getProperty("user.home")+"/Desktop";
path=path.replace("\\", "/");
return path;
}
public static void main(String[] args){
Folder obj=new Folder();
obj.input();
obj.compute();
}
}
import java.util.*;
public class Folder{
Scanner scan=new Scanner(System.in);
String folderName;
public void input(){
try{
System.out.printf("Folder Name: ");
folderName=scan.nextLine();
}
catch(InputMismatchException e){
System.err.println("Error Occured!\n"+e.getMessage());
System.exit(0);
}
}
public void compute(){
String path=getDesktopPath();
File folder=new File(path+"\\"+folderName);
if(!folder.exists())
folder.mkdir();
else{
System.err.println("Folder Already Exists!");
System.exit(0);
}
if(folder.exists())
System.out.println("Folder Created!");
else
System.out.println("Folder not Created!");
}
public String getDesktopPath(){
String path=System.getProperty("user.home")+"/Desktop";
path=path.replace("\\", "/");
return path;
}
public static void main(String[] args){
Folder obj=new Folder();
obj.input();
obj.compute();
}
}
Comments