• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

DOS command in java program question..

 
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?

 
Bartender
Posts: 10336
Hibernate Eclipse IDE 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.
 
author
Posts: 23883
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux 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
Hibernate Eclipse IDE 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
Posts: 23883
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux 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
Posts: 23883
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux 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
Posts: 23883
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux 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
 
Time flies like an arrow. Fruit flies like a banana. Steve flies like a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic