Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DOS command in java program question..

 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I can delete the folder directly using DOS command from java program,


now I need to now how to remove a folder with the confirmation.

Here is in details.
1) apply rmdir <folder Name>
2) ask for confirmation Y/N
3) if Y, remove else keep it as it is

Can we do this from java program?

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but wouldn't it be easier to do the deletion via the classes in the java.io package rather than using the the command shell?
 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried with DEL command in DOS, it supports to delete files only with confirmation what I expected.
It supports to remove files only, look at this
then It prompts me to remove the file, Y, it is

Ok later I used the same command to remove a file with java program

the console process is still going for longer, it never stopped to display the results. I don't know what's going with this.
 
Henry Wong
author
Marshal
Pie
Posts: 20899
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Paul. Would it not be easier to use the classes in the java.io package?


Furthermore, by going this route, you won't be platform independent anymore -- the application would require the DOS commands. With the java.io package, it would work on any platform supported by Java.

Henry
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But why? What does the console give you which you need over and above IO via Java? It seems you are possibly creating work for yourself.
 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please look at the code below, I Used java.io package, but I don't get what you are suggesting with that


while executing the above code, When the controller comes to stdInput.readLine() (To display the output), the process is struck and cannot move from there.
I blocked the while loop and executed, the process is done but file is not deleted.

Could you please suggest me with your java.io knowledge how to del file/folder?
 
Henry Wong
author
Marshal
Pie
Posts: 20899
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumar Kuchipudi wrote:Could you please suggest me with your java.io knowledge how to del file/folder?


We mean something like...



Henry
 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wang,

I know with that, but we are having a requirement to remove them through DOS commands executing from java program.
 
Henry Wong
author
Marshal
Pie
Posts: 20899
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumar Kuchipudi wrote:I know with that, but we are having a requirement to remove them through DOS commands executing from java program.


Why didn't you just say so? We kept asking you why you were doing something so silly, and you just ignored it, which peaked our interest.

Well... good luck. Hopefully, someone did something similar.

Henry
 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi wang,

I thought you have different idea with java.io, thats why I was waiting for the result from you. I'm not in that way what you think. I dont know why feel angry on this moment.

Thanks from your time.
 
Henry Wong
author
Marshal
Pie
Posts: 20899
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont know why feel angry on this moment.


I am not angry. Am I coming across as such? Hmmm.... Don't know why. My friends sometimes say the same thing.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic