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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "aborting a process in java" Watch "aborting a process in java" New topic
Author

aborting a process in java

Vaskar Dasgupta
Greenhorn

Joined: Jul 20, 2001
Posts: 25
i am reading data from MS-SQL6.5 DB and transferring those data into a XML file.The whole process is done by click of a button.While writing the data into the XML file,i want to provide the option of aborting that process.I use java IO to write data into the file.How can i achieve the functionality of aborting the "file writing" process?can anyone suggest godd program logic for this ?


Kindly reply back.
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
I suggest that you delegate the writing part to a dedicated thread. The run of that thread should be controlled by a boolean condition, like while(!buttonPressed). When you press the abort button you should switch the value of buttonPressed from false to true, thus aborting the thread. You should know, though, that this would let the file being written in a unknown state ! I think you don't care !
Let me know if it's not clear
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
I suggest you read the Swing tutorial, especially the section about threads and Swing. The SwingWorker class mentioned there may serve you well. Top it off with the bit about progress bars and this bit about threads and you should be well-equipped for your journey.
- Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: aborting a process in java
 
Similar Threads
Large XML
reading data from xml file asynchronously
reading data from xml file asynchronously
reading data from xml file asynchronously
How to read from XSD generated database and put that data into XML file.