File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes restart Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "restart" Watch "restart" New topic
Author

restart

jp staff
Greenhorn

Joined: Sep 10, 2001
Posts: 5
I am trying to figure out how to restart a program after I have already run through it. For instance, Would the user like to start over again, where should I place this code and should I use a Loop of some sort
Thanks Jpre
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
I think you need to provide more info to get this answered. Is it a GUI? How is it started? What does it do?
jp staff
Greenhorn

Joined: Sep 10, 2001
Posts: 5
He is my code in a nutshell, after it goes through everything I want to beable to ask the user if it would like to go through the process again

[This message has been edited by Cindy Glass (edited September 12, 2001).]
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
JP
Just put the entire working part of the main in a loop. Here it is in a do loop:

you'll need to declare the int variable doOver in the code above where the loop starts.
One point though, from a design stand point. You're collecting the information from the user in inputDialogs but then you show the results on the command line. That is a little hard to follow and some users might get confused. It might be better to do it all one way or the other - all on the command line or all with dialog boxes.
hope that helps you out
------------------
Dave
Sun Certified Programmer for the Java� 2 Platform
[This message has been edited by Dave Vick (edited September 10, 2001).]


Dave
jp staff
Greenhorn

Joined: Sep 10, 2001
Posts: 5
Thanks dave that helps me out a lot, I am very new to java, and still think in terms of c, to take input from the command line from the user, How do I do that. My book dosen't go into to much detail. Thanks Jp
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
JP
Here this should give you good start on it.
declare this before the actual loop:
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
At the bottom of the loop, instead of the dialog use this:

If you need more let me know

------------------
Dave
Sun Certified Programmer for the Java� 2 Platform
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: restart