Skip to main content

Posts

Showing posts from September, 2012

Java Program to create an File and if exists then the user will have the choice to Replace that File or not

import java.io.*; import java.util.*; import system.*; public class ReplaceFiles{     Scanner scan=new Scanner(System.in);     String fileName;     char ch;     public void input(){         try{             System.out.printf("Enter File Name: ");             fileName=scan.nextLine();             ReplaceFiles();         }         catch(InputMismatchException e){             System.err.println("Error Occured!\n"+e.getMessage());             System.exit(0);         }     }   ...

Java Program to calculate the cube root of any number

import java.io.*; import java.util.*; public class CubeRoot{     Scanner scan=new Scanner(System.in);     int num;     public void input(){         try{             System.out.printf("Enter any Number: ");             num=scan.nextInt();         }         catch(InputMismatchException e){             System.err.println("Error Occured!\n"+e.getMessage());             System.exit(0);         }         catch(NumberFormatException e){             System.err.println("Error Occured!\n"+e.getMessage()); ...

Java Program to open Notepad

import java.io.*; import java.util.*; public class Notepad{     public Notepad(){         try{             Process process=Runtime.getRuntime().exec("notepad.exe");         }         catch(Exception e){             System.err.println("Error Occured!\n"+e.getMessage());             System.exit(0);         }     }     public static void main(String[] args){         Notepad notepad=new Notepad();     } }

Java Program to open Wordpad

import java.io.*; public class Wordpad {     public Wordpad(){         try{             Process pro=Runtime.getRuntime().exec("write.exe");         }         catch(IOException e){             System.err.println("Error Occured!\n"+e.getMessage());             System.exit(0);         }     }     public static void main(String[] args){         Wordpad obj=new Wordpad();     } }

Java Program to open Folder

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()){          ...

Java Program to create an Folder

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);   ...

Java Program to edit Files

import java.awt.*; import java.io.*; import java.util.*; public class EditFile {     Scanner scan=new Scanner(System.in);     String filePath;     byte error=0;     public void input(){         try{             String defaultPath=System.getProperty("user.home")+"\\";             System.out.printf("File Path: "+defaultPath);             filePath=scan.nextLine();             filePath=defaultPath.concat(filePath);         }         catch(InputMismatchException e){         System.err.println("Error Occured!\n"+e.getMessage());         System.e...

Java Program to delete any File or Folder

import java.io.*; import java.util.*; public class Delete{     private Scanner scan=new Scanner(System.in);     private String path;     public void input(){         try{             System.out.printf("File/Folder Path: ");             setPath(getScan().nextLine());         }         catch(InputMismatchException e){             System.err.println("Error Occured!\n"+e.getMessage());             System.exit(0);         }     }     public void compute(){         File deleted=new File(getPath());      ...

Java Program to create an new File

import java.io.*; import java.util.*; import java.awt.*; public class CreateFile {  Scanner scan=new Scanner(System.in);  String fileName;  char ch;  BufferedReader buff=new BufferedReader(new InputStreamReader(System.in));  public void input(){      try{          System.out.printf("File Name: ");          fileName=scan.nextLine();      }          catch(InputMismatchException e){              System.err.println("Error Occured!\n"+e.getMessage());          System.exit(0);          }            }  public void compute(){      try{       String path=getDesktopPath(); ...

Java Program to open Control Panel

import java.io.*; public class ControlPanel{     public ControlPanel(){         try{             Process pro=Runtime.getRuntime().exec("control.exe");             System.exit(0);         }         catch(IOException e){             System.err.println("Error Occured!\n"+e.getMessage());             System.exit(0);         }     }     public static void main(String[] args){         ControlPanel obj=new ControlPanel();     } }

Java Program to display few Operating System (OS) details

public class OperatingSystem {     public OperatingSystem(){         try{         String os;         os=System.getProperty("os.name");         System.out.println("Your Operating System (OS): "+os);         os=System.getProperty("os.version");         System.out.println("Your OS Version: "+os);         os=System.getProperty("user.name");         System.out.println("User Name: "+os);         os=System.getProperty("user.home");         System.out.println("Home Directory: "+os);         os=System.getProperty("user.dir");         System.out.println("Current Workin...