How to cancel downloading process in JAVA ftp?

I tried to write a java ftp client to transfer files within our network. One of very usefully function I want to add is to cancel the transfer while files
are downloading or uploading. I can do this on file uploading by closing "ftpclient.put(filename) methods at anytime, but have trouble on closing "ftpClient.get(remoteFilename)". When I tried to close it by using "in.close()", the program stucked. I even tried to kill the thread, but no luck. Can any one give me a hint? Here is the code:
protected void downloadfile ()
byte [] buffer = new byte[BUFFER_SIZE];
try{
FileOutputStream out = new FileOutputStream(Localfilename);
InputStream in = ftpClient.get(remoteFilename); //downloading
// Write to local file
while (true && !cancelORnot)
// write to file
} catch ( Exception ex) { }
finally
try {
if (out ! = null)
out.close(); // this can be closed at any time
if (in != null)
in.close(); // This one stucked if it is in the middle
// of downloading and can not disconnect to the
// ftp server
catch ( IOException ex)
}

How does the ftpClient.get("fileName") work? Also, are you running everything in the EventDispatchThread? If your running everything in the EventDispatchThread then ftpClient.get() will need to finish before an event can be handled.
If thats the case, you could use a SwingWorker to do the downloading so that the Event Thread is available to handle the cancel event.

Similar Messages

  • How to invoke BPEL process from JAVA API

    Hi Guys
    Any idea if you can tell me how to invoke BPEL process from JAVA API ?
    What to do in BPEL process manager to achieve that?
    Regards
    Deepak

    See http://download-west.oracle.com/docs/cd/B31017_01/integrate.1013/b28981/invoke.htm#sthref1373 and the JavaDocs http://download-west.oracle.com/docs/cd/B31017_01/integrate.1013/b28986/toc.htm.

  • How to cancel the process in initiator of human task in 11g?

    human task as the initiator of the process, by default there is only a SUBMIT button, how to cancel the process then?
    if I just close the form, a task will still created in the task list, still in initiator step. what if I don't want this?
    I tried to add an "CANCEL" output for this , if the output is CANCEL then go to then end activity, but seems it doesn't work. anyone got a better solution? thank you.

    You should be able to use the "Withdraw" action for this - available from the task Actions button/drop down on the human task form.

  • How to cancel downloading in JAVA FTP?

    I tried to write a java ftp client to transfer files within our network. One of very usefully function I want to add is to cancel the transfer while files
    are downloading or uploading. I can do this on file uploading by closing "ftpclient.put(filename) methods at anytime, but have trouble on closing "ftpClient.get(remoteFilename)". When I tried to close it by using "in.close()", the program stucked. I even tried to kill the thread, but no luck. Can any one give me a hint? Here is the code:
    protected void downloadfile ()
    byte [] buffer = new byte[BUFFER_SIZE];
    try{
    FileOutputStream out = new FileOutputStream(Localfilename);
    InputStream in = ftpClient.get(remoteFilename); //downloading
    // Write to local file
    while (true && !cancelORnot)
    // write to file
    } catch ( Exception ex) { }
    finally
    try {
    if (out ! = null)
    out.close(); // this can be closed at any time
    if (in != null)
    in.close(); // This one stucked if it is in the middle
    // of downloading and can not disconnect to the
    // ftp server
    catch ( IOException ex)
    Thanks!

    Thank you for replying. I am sorry I forgot including FTP API
    information.The FTP API I used is from SUN, JDK, sun.net.ftp.FtpClient. The method is " InputStream in = ftpClient.get(remoteFilename)"and "in.close()" should close downloading. while it is still downloading, in.close() will not work and hang my program on forever. I am just wondering if there is trick to close downloading whenever I want especially in case that network connection is too slow and I want to cancel the job.

  • How to cancel downloading app in ipod touch that status is "waiting"??

    I've choose "update all" from app store. Because a slow connection, all app that i've update is still "waiting" till now. I want to cancel the process and I've tried to reboot but still does'nt work. So, how to cancel those "waiting" app???

    iOS 4.3.1 has features for deleting it before you started downloading. iOS 4.2 does not

  • How to Cancel Succesful Processed Messages

    Hi Experts,
    How to cancel the succesful processed messages which reached Integration Server and sender Adapter engine in XI.
    Thanks
    Venkat Anil

    We cannot cancel Successfully processed messages.
    However you can configure Archiving and/ or deletion of successfully processed messages to remove the entry from the DB
    Edited by: abhishek salvi on Jan 8, 2010 2:57 PM

  • How to call BPM process from Java

    Hi All,
    Can anybody help how to call a BPMN process from java.Please give any sample exaple on this.
    Thanks,
    Ganesh

    For 11g BPM please look at this post. Re: Getting while running the BPEL process from java
    It references an ATeam example app that can start processes from a web client. But the Java APIs are described too.

  • CVI2013 f1: how to cancel build process?

    how to cancel the build process after it's started?
    I can't find a way...
    Vix
    In claris non fit interpretatio
    Using LV 2013 SP1 on Win 7 64bit
    Using LV 8.2.1 on WinXP SP3
    Using CVI 2012 SP1 on Win 7 64bit, WinXP and WinXP Embedded
    Using CVI 6.0 on Win2k, WinXP and WinXP Embedded
    Solved!
    Go to Solution.

    Hello Wolfgang!
    Yes, my answer to vix's initial question was basically the same as your's: the 'Cancel Build' menu item from the Build menu.
    As of CVI 2013, the build process is not longer blocking the ADE UI anymore, so users can operate the CVI ADE independent of the currently running build process. Hence, the modal dialog from CVI 2012 has been removed. Because the dialog was removed, we moved the ability to cancel the current build over to the CVI ADE menu, amoung the other menu items related to the build process (e.g. Build, Rebuild, Batch Build...). However, we didn't want to modify the behavior of the STOP button, because it's main purpose has been closely targeted towards controlling the execution state of a debugged program. If we have changed it's behavior, we would also have to change it's naming, i.e. currently 'Terminate Execution' toolbar button.

  • HT5772 How to cancel downloading update?

    I accidently hit the wrong button. How can I cancel downloading update?

    Hit pause... Trash the download from the download folder. Also clear the downloads... in Safari.

  • How to Cancel Event processing

    I have integrated a WD-ABAP application in Portal. I want to change the behaviour of Close button (By default it closes the browesr window !!). I am able to catch the FPM_CLOSE event and execute my custom code, but the problem is, after my code gets executed, the standard handler for FPM_CLOSE also gets executed. Is there any way to cancel the processing of standard handler. In debug mode I was able to do it by clearing the mv_event_id. It's a readonly parameter and I cannot do it programmatically.
    Thanks
    Prashant

    Solved it by changing the ev_result parameter to failed after executing my custom handler.
      ev_result = if_fpm_constants=>gc_event_result-failed
    Thanks
    Prashant

  • How to invoke Bpel process  from java using 'bpel process WSDL'

    I want to call bpel process from java using bpel wsdl.
    could any one point me to any url/sample.
    Thanks
    Nagajyothy

    Hi Seshagiri,
    Thanks for providing links and initial steps to create web service proxy(using Jdeveloper 11g).
    I created a web service proxy.
    provided the needed inputs.
    when I ran the client app, bpel process(has a human task) got invoked but faulted with exception as below
    Operation 'initiateTask' failed with exception 'EJB Exception: : java.lang.ExceptionInInitializerError[[
         at oracle.tip.pc.services.common.ServiceFactory.getAuthorizationServiceInstance(ServiceFactory.java:147)
         at oracle.bpel.services.workflow.task.impl.TaskService.initiateTask(TaskService.java:1159)
         at oracle.bpel.services.workflow.task.impl.TaskService.initiateTask(TaskService.java:502)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
    please help me in solving the above problem.
    Thanks
    Nagajyothy

  • How To Cancel Download of Podcast

    I recently tried downloading previous episodes of a Fringe Podcast through Itunes on my computer unsuccessfully so I then tried to do the downloads on my Iphone through Itunes. Again it was unsuccessful this time because the files were too big if I remember correctly..........anyways heres my problem......when I go to the download screen on my Iphone the 3 Fringe Podcats still remain there, 2 are stuck on processing and the other says waiting. I want to remove them all from that download screen but do not know how. Any help would be greatly appreciated.

    Try resetting the iPad and see if the podcasts will finish downloading, then delete them if you don't want them.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • HT3662 how to cancel downloading Mavericks while in progress on macbook pro

    I started downloading latest Mavericks OS and realized I had already downloaded the latest version. Cannot cancel the download.
    What do I do?

    Thank you for replying. I am sorry I forgot including FTP API
    information.The FTP API I used is from SUN, JDK, sun.net.ftp.FtpClient. The method is " InputStream in = ftpClient.get(remoteFilename)"and "in.close()" should close downloading. while it is still downloading, in.close() will not work and hang my program on forever. I am just wondering if there is trick to close downloading whenever I want especially in case that network connection is too slow and I want to cancel the job.

  • HT2347 How to cancel downloading files now

    How do you cancel a presently downloading file?

    Hit pause... Trash the download from the download folder. Also clear the downloads... in Safari.

  • HT201272 how to cancel download of movie

    My son purchased a movie and it will take 3 hours to download into his iPod! It is preventing other downloads and we would like to know if gthere is a way to not have to download the movie and just cancel it!

    How can I cancel the download of a movie on iTunes?

Maybe you are looking for

  • ORA-00933 error when selecting from remote DB

    Hi to all. Consider the following: SELECT col1, col2 FROM Table1@remoteOK. SELECT col1, col2 FROM Table1@remote LEFT JOIN Table2@remote ON (...)OK. INSERT INTO Local_Table (a, b)SELECT col1, col2 FROM Table1@remote OK. INSERT INTO Local_Table (a, b)S

  • Add more Recipients to Email Notification.

    Hi All, Could you help me to add 2 Recipient in Email Notification in WSUS?

  • Where to find oraks.jks keystore?

    Hi.. Which software should i get in order to get the oraks.jks keystore?

  • Work Order related Question

    Hello, I want to know which table or FM can be used to get plan cost for a work order (Header level) in IW33 > Cost > Plan Cost. Please let me know. Thanks.

  • ICal Sync creates strange duplicates with every sync

    Hi guys, I read quite a few threads here as well as googled for my problem, but none of the solutions helped. I don't know if it's just a sync error or more to it, but this is happening (it started probably after updating to iOS 6.1 - before that eve