import java.io.*;
import java.util.*;
public class OpenFolder{
Scanner scan=new Scanner(System.in);
String folderPath, defaultPath;
public void folderPath(){
try{
defaultPath=System.getProperty("user.home")+"\\";
System.out.printf("Folder Path: "+defaultPath);
folderPath=scan.nextLine();
scan.remove();
folderPath=defaultPath.concat(folderPath);
File check=new File(folderPath);
if(!check.exists()){
System.err.println("Invalid Path!\n"+folderPath);
folderPath();
}
}
catch(InputMismatchException e){
System.err.println("Error Occured!\n"+e.getMessage());
System.exit(0);
}
}
public void openFolder(){
try{
Process process=Runtime.getRuntime().exec("explorer.exe "+folderPath);
}
catch(IOException e){
System.err.println("Error Occured!\n"+e.getMessage());
System.exit(0);
}
}
public static void main(String[] args){
OpenFolder obj=new OpenFolder();
obj.folderPath();
obj.openFolder();
}
}
import java.util.*;
public class OpenFolder{
Scanner scan=new Scanner(System.in);
String folderPath, defaultPath;
public void folderPath(){
try{
defaultPath=System.getProperty("user.home")+"\\";
System.out.printf("Folder Path: "+defaultPath);
folderPath=scan.nextLine();
scan.remove();
folderPath=defaultPath.concat(folderPath);
File check=new File(folderPath);
if(!check.exists()){
System.err.println("Invalid Path!\n"+folderPath);
folderPath();
}
}
catch(InputMismatchException e){
System.err.println("Error Occured!\n"+e.getMessage());
System.exit(0);
}
}
public void openFolder(){
try{
Process process=Runtime.getRuntime().exec("explorer.exe "+folderPath);
}
catch(IOException e){
System.err.println("Error Occured!\n"+e.getMessage());
System.exit(0);
}
}
public static void main(String[] args){
OpenFolder obj=new OpenFolder();
obj.folderPath();
obj.openFolder();
}
}
Comments