Hello :
I have this question and I solve the half of it I wont your help in other codes..
We have do a code for every commend ... In this project you will develop many commands that are related to file operations, as in the following list (red colors):

1.pwd: to print the current working directory, i.e, where are you now in the file system.
2.dir [file1/dir1 file2/dir2 etc]: to list the files/subfolders of one or more file/subfolder. In case fName is file then the file information such as (name (use getName method under File) and size (use length method) ) will be listed. In case the file does not exist the message "file/folder was not found". [Hint: under File class there is a method: listFiles which list all the files/subfolders of a given folder]
3.rename oldName newName: to rename a file/folder with new name/folder
4.more file1 [file2][file3] ...: to display the contents of one or more files
5.copy file1 file2: to make new copy of file1 to one or more destinations. In case any of the destination file names exist a confirmation from the user for overwriting should be requested before copying.
6.Append file1 file2 dest: to append/combine source files file1 and file2 in one file dest. In case dest does exist, a confirmation from the user for overwriting should be granted first.
7.findstr word file: to search a word in a file. Each line that contains the word in the file should be displayed along with the line number.
8.Del file1 [file2 ...]: to delete one or more file/directory from the file system.
9.mkdir folder1 [, folder2, etc.]: to create one or more folders.
10.touch file1 [file2 etc..]: to create a new empty file file1 (file2, etc...)
11.help [command]: to display the usage of all command [ or specific one].
12.bye : to exit the program
13.exit: to exit the program

I want numbers 2,3,5,6,9,10,11
Ihis is what I have done...

public abstract class AbstractCommand{
    protected String commandName;
    protected String[] parameters;

    public AbstractCommand(){}
    public AbstractCommand(String name, String[] params){
        this.commandName = name;
        this.parameters = params;

    public abstract void execute();
    public abstract String usage();

public class PWD extends AbstractCommand{
    public PWD(String name, String[] params){
    public void execute(){
        File f = new File( "."); // current directory is represented by .
        System.out.println( f.getAbsolutePath());
    public String usage(){
        return "pwd : to print the current working directory";

public class More extends AbstractCommand{
    public More(String name, String[] params){
     //implement the method execute
    public void execute(){
        if(this.parameters.length == 0){
        for(String fn : this.parameters){
            File f = new File(fn);
            if(f.exists()) displayFile(f);
                System.out.println("file" + fn + " was not found...");
    public void displayFile(File file){
                 //write code to open and display the lines of text file

    public String usage(){
        return "more file1 [file2] [file3] ... : to display one or more files";

public class Exit extends AbstractCommand{
    public Exit(String name, String[] params){
    public void execute(){
    public String usage(){
        return "exit/bye : to exit";

Public class Dispatcher{
    private String commandName;
    private String[] parameters;

    public Dispatcher(String cmd){
               use String.split or Scanner class to extract the command Name and the 
              list of paramters.
             for example the parameter cmd might be:  MORE  abc.txt  hello.txt
             you need to parse cmd such that the value of command name is “more”, and the 
             list of parameters are [ abc.txt, hello.txt]
    // provide a method getCommand Object
    public AbstractCommand getCommandObj(){
            return new More(this.commandName, this.parameters);
        else if(commandName.equalsIgnoreCase("dir"))
            return new DIR(this.commandName,this.parameters);
       // more commands to be added accordingly
        else return null;

Public class CommandPrompt{
   Private Scanner scanner = new Scanner( System.in);

    public void start(){
        Dispatcher dispatcher =null;
        AbstractCommand cmdObj =null;

            String commandLine = getCommand();
            dispatcher = new Dispatcher( commandLine);
            cmdObj = dispatcher.getCommandObj();
            if(cmdObj == null){
                System.out.println("command not found...");

  // getting commands from the user
  public String getCommand(){
        return scanner.nextLine();

    public static void main(String[] args){
        CommandPrompt cmd = new CommandPrompt();

This is the work I have done....
please help me ... I really need your help
please reply as soon as possible

No one here will write code for you. You need to ask a more specific question. What is it you are having problems with? Choose one issue to ask about at a time. If you have a question on a different topic, then start a new thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.