I use javaFx WebViewBrowser to download ZIP file, the page no action

I use javaFx WebViewBrowser to download ZIP file, the page no action; other tools example chrome ,ie can download the zip file .
so can you writer a download zip file example for me ?
thanks ,my english is so bad ,sorry !!! :)

WebView doesn't have a built in file downloader - you have to implement it yourself.
You can find a sample implementation for file downloads in JavaFX here =>
http://www.zenjava.com/2011/11/14/file-downloading-in-javafx-2-0-over-http/
That sample does not include the hooks into WebView to trigger the downloads.
You will need to trigger off the mime type or the file extension in the url.
A rudimentary sample trigger a download off of webview is provided in the code below.
For a nice solution, you would probably want to spin the downloader off with it's own UI similar and manage the download itself as a JavaFX Task similar to how the zenjava component works.
Code adapted from => http://code.google.com/p/willow-browser/source/browse/src/main/java/org/jewelsea/willow/BrowserWindow.java
// monitor the location url, and if it is a pdf file, then create a pdf viewer for it, if it is downloadable, then download it.
view.getEngine().locationProperty().addListener(new ChangeListener<String>() {
  @Override public void changed(ObservableValue<? extends String> observableValue, String oldLoc, String newLoc) {
    if (newLoc.endsWith(".pdf")) {
      try {
        final PDFViewer pdfViewer = new PDFViewer(false);  // todo try icepdf viewer instead...
        pdfViewer.openFile(new URL(newLoc));
      } catch (Exception ex) {
        // just fail to open a bad pdf url silently - no action required.
    String downloadableExtension = null;  // todo I wonder how to find out from WebView which documents it could not process so that I could trigger a save as for them?
    String[] downloadableExtensions = { ".doc", ".xls", ".zip", ".tgz", ".jar" };
    for (String ext: downloadableExtensions) {
      if (newLoc.endsWith(ext)) {
        downloadableExtension = ext;
        break;
    if (downloadableExtension != null) { 
      // create a file save option for performing a download.
      FileChooser chooser = new FileChooser();
      chooser.setTitle("Save " + newLoc);
      chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Downloadable File", downloadableExtension));
      int filenameIdx = newLoc.lastIndexOf("/") + 1;
      if (filenameIdx != 0) {
        File saveFile = chooser.showSaveDialog(view.getScene().getWindow());
        if (saveFile != null) {
          BufferedInputStream  is = null;
          BufferedOutputStream os = null;
          try {
            is = new BufferedInputStream(new URL(newLoc).openStream());
            os = new BufferedOutputStream(new FileOutputStream(saveFile));
            int b = is.read();
            while (b != -1) {
              os.write(b);
              b = is.read();
          } catch (FileNotFoundException e) {
            System.out.println("Unable to save file: " + e);
          } catch (MalformedURLException e) {
            System.out.println("Unable to save file: " + e);
          } catch (IOException e) {
            System.out.println("Unable to save file: " + e);
          } finally {
            try { if (is != null) is.close(); } catch (IOException e) { /** no action required. */ }
            try { if (os != null) os.close(); } catch (IOException e) { /** no action required. */ }
        // todo provide feedback on the save function and provide a download list and download list lookup.
});

Similar Messages

  • Problem on windows xp with downloaded zip file

    Hi,
    I have written a JSP to download file which is as follows
    try
    response.setContentType("application/download");
    response.setHeader("Content-Disposition","attachment;filename=<FileName>");
    int iRead;
    FileInputStream stream = null;
    try
    File f = new File(<FilePath>);
    stream = new FileInputStream(f);
    while ((iRead = stream.read()) != -1)
    out.write(iRead);
    out.flush();
    finally
    if (stream != null)
    stream.close();
    catch(Exception e)
    //out.println("Exception : "+e);
    After downloading zip file, could not extract files on windows XP by using any tool or built-in extractor i.e. compressed(zipped)folders (error: compressed folder invalid or corrupted).
    But this works on win2k or win98
    How can i work with it or can anyone tell me a solution to handle such a problem.
    Thanks in advance.
    Rajesh
    [email protected]

    This could be a problem with the built-in ZIP program in Win XP - it's possible that the ZIP you are downloading (uploading?) is simply incompatible with the XP program. In Win 98 & 2000, you would have to use your own ZIP program, e.g. Winzip, and that can handle more formats that the XP program.
    Try installing the same ZIP program that you have on w98/2k on your XP machine, and see if you can open the uploaded file using it.

  • How to create a Web Dynpro Project from Downloaded zip file?

    Hi,
    I have been working in Java Web Dynpro for last 1 month but not able
    to create any Web Dynpro from Downloaded zip file?
    Can anybody tell me how to create a Java Web Dynpro Project from
    Donloaded zip code?
    Regards
    Kaushik Banerjee

    Hi Kaushik,
    You can add the existing zip file into your workspace by the following way -
    First open the NWDS and create a new project by clicking file -> new -> Project -> Simple -> Project
    and then File -> Import -> zipfile and then browse the zip file into the newly created project.
    or else you can also unzip the zip file into a folder and then Use the option of Import an exisitng project into workspace. You can find this in the File-> import -> Existing project into workspace. and then use the Browse option to browse to the existing folder.
    After importing the project you need to rebuild the project
    Regards,
    Raju Bonagiri.

  • How do I get a download zip file from firefox to my desktop

    I download zip files from different web sites and they go to the download folder in firefox, but I can't access them to open,unzip, or work with them on my computer offline. How can I move them from the download folder in firefox to my computer desktop?

    Hi,
    In order to open ZIP files, you have to download an app to enable the opening of the ZIP. Here's one you can use: https://play.google.com/store/apps/details?id=com.winzip.android
    Next, when you install that, open it and go to your Download directory. It should either be in sdcard0, sdcard, or sdcard1, then go to Download.
    Once you find it, touch and hold the file, then click '''Unzip here''' and it will extract the files in the ZIP folder.
    Let me know if this works!

  • Problem downloading ZIP file with Squid-3.0

    Hi,
    I have upgraded my Linux CentOS squid proxy servers to Squid version 3.0. Since then I can not download the following file it just hangs :
    http://download.oracle.com/otn/java/sqldeveloper/sqldeveloper-1.5.5.59.69.zip
    I dont see any error in the squid logs or on my firewall.
    I can however download it on one of the older servers still running Squid version 2.6.
    It is just very strange as I can download ZIP files from any other website with the upgraded servers.
    Any ideas on what might cause this ?
    Thanks
    JHEFER
    Edited by: jhefer on Nov 19, 2009 12:15 AM

    If you have already interested, I found the solution. The problem is that oracle website (and probably others) uses “Vary” field in the header and squid doesn’t support this (by default). You have to download squid sources on http://www.squid-cache.org/Versions/ and compile these with “--enable-http-violations” parameter :
    *./configure ‘--enable-http-violations’ ‘…’ ‘…’*
    make all
    make install
    I hope this solution will be very useful to you.
    Laurent

  • Cant download zip.files

    Hi there,
    I cant download .zip files or software updates from any site and Ive tried several browsers.
    It just opens a new page and remains blank? or does nothing.
    I have no firewall on. And have no anti virus software.
    I can click on pdfs and they download fine.
    I using a new intel imac.
    Safari, firefox.
    Hope you can help, thanks.

    Fixed it, it was a program called speed downlod, i removed it and now i can download files, yay!
    speed downloader....more like Stop downloader

  • Can't expand downloaded zip-files

    I download zip files and can't expand them. If I compress my own files, they are easily expanded. The error message reads: Unable to unarchive "document.zip" into "Desktop". (Error 1 - Operation not permitted.)
    I have tried to create a folder and drop the zipped file there and expand it. Checked permission, which are read & write.
    Any suggestions?

    Sorry, I just don't know for sure as I never use the archive function.
    As most of my stuff is either graphics or movies I have a deep mistrust of anything that might affect quality!

  • When i download zip files it says decompression failed

    when i download zip files on some occasions i get decompression failed

    The current version of the built-in Archive Utility has problems with some zip files. Use "The Unarchiver" instead -- free in the App Store.

  • I would like to use GarageBand to remaster downloaded music files that are in iTunes.  Poorly mastered files keep clipping and damaging my speakers.  When I try to use an iTunes file as a new project, it greys out the iTunes songs so I can't select them.

    I would like to use GarageBand to remaster downloaded music files that are in iTunes.  Poorly mastered files keep clipping and damaging my speakers.  When I try to use an iTunes file as a new project, it greys out the iTunes songs so I can't select them.  Any ideas?

    As I said - look whether your original file is damaged or not. If not, I wouldn't change it and find out what in your system makes it sound like it's clipping.
    Good sound file, with volume maxed out. No need to change anything.
    The same song clipped - no chance to repair.

  • I can not download any files using Safari ? when I choose to download application file the URL include the file name and stop responding. Any help??

    I can not download any files using Safari ? when I choose to download application file the URL include the file name and stop responding. Any help??

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. For instructions, launch the System Preferences application, select Help from the menu bar, and enter “Set up a guest account” (without the quotes) in the search box.
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem(s)?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault in Mac OS X 10.7 or later, then you can’t enable the Guest account. The Guest login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows:
    Be sure your Mac is shut down.
    Press the power button.
    Immediately after you hear the startup tone, hold the Shift key. The Shift key should be held as soon as possible after the startup tone, but not before the tone.
    Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    *Note: If FileVault is enabled under Mac OS X 10.7 or later, you can’t boot in safe mode.
    Test while in safe mode. Same problem(s)?
    After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2.

  • After downloading my file the word document is mostly gibberish.  Why? service used exportPDF

    After downloading my file the word document is mostly gibberish.  Why? Service used "exportPDF".

    Hi shelbyrn,
    The quality of a conversion really depends on the quality of the original PDF file. Please see Will Adobe ExportPDF convert both text and form... | Adobe Community.  Do you know what or how the PDF file was created?
    You may have better luck by disabling OCR as described in this document: How to disable Optical Character Recognition (O... | Adobe Community. (Note, however, that is  option isn't optimal if the PDF was created from a scanned document; you'd want OCR enabled to convert the image text in the PDF to editable text).
    Best,
    Sara

  • I am unable to download zip files

    http://avl1.teltonika.lt/Downloads.FM22
    I am unable to download zip files from this URL

    Thanks, I just needed to update (not to reset).

  • Can't download .zip files

    When downloading from file sharing sites, I can't download .zip files. Downloading other compressed files such as .rar is automatic upon clicking on the file. How do I change the settings to include .zip files. Thanks

    Below is a link I uploaded myself. It is a few random songs I zipped and uploaded to the file sharing service Hotfile. When I attempt to go to the link myself, safari will not open the page and it also will not auto download the file as it does with other compressed files such as .rar. If I compress the file in .rar format or simply upload an MP3 to Hotfile or Rapidshare, I can click on the link and it automatically downloads.
    Link http://hotfile.com/dl/48619201/97e4208/Archive_2.zip.html

  • Macbook Pro won't download .zip files correctly

    I have a Macbook Pro (13'' June 2012 model, 500GB HDD, 4GB RAM, 2.5GHz i5 processor, OS X 10.9.5) and whenever I try and download .zip files, on either Chrome or Safari, it doesn't know what size the file actually is meant to be (as seen below) and so keeps downloading constantly. Each time I cancel it (in some cases after it's reached over 100MB even though the file is a 9 song album), I get no files back out. Is there anyway to fix this so I can actually download them?

    Download Stuffit Expander from the App Store or directly from the manufacturer.  The software is free.  It can open any file you throw at it - after you set up its preferences to do so.

  • After downloading a file, the downloads window pops up, but is always empty. the downloaded files are not visible.

    After downloading a file, the Downloads window pops up but it is always empty. The files downloaded are not visible on this window. In order to access them, they must be sought out via windows explorer. Any ideas? Thanks.

    Be sure Options > Privacy > "Remember download history" is checked.
    *[https://support.mozilla.com/en-US/kb/Options%20window%20-%20Privacy%20panel Options window-Privacy panel]
    If you want to retain download history, do not clear Download History when using Clear Recent History or "Clear history when Firefox closes" > Settings
    *[https://support.mozilla.com/en-US/kb/Clear%20Recent%20History Clear Recent History]
    *Clear history when Firefox closes: [https://support.mozilla.com/en-US/kb/Options%20window%20-%20Privacy%20panel Options window-Privacy panel]
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    Not related to your question, but...
    You need to update some plug-ins:
    *Plug-in check: https://www-trunk.stage.mozilla.com/en-US/plugincheck/
    *Adobe Shockwave for Director Netscape plug-in: [https://support.mozilla.com/en-US/kb/Using%20the%20Shockwave%20plugin%20with%20Firefox#w_installing-shockwave Installing ('''''or Updating''''') the Shockwave plugin with Firefox]
    *Adobe PDF Plug-In For Firefox and Netscape: [https://support.mozilla.com/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox]
    *Next Generation Java Plug-in for Mozilla browsers: [https://support.mozilla.com/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java in Firefox]

Maybe you are looking for

  • JDeveloper 9i, Foreign Keys and LOVs.

    Greetings all, I'm using Jdev 9i to try and create some maintenance applications quickly. These applications are pretty standard; insert, update, delete, some validation, including foreign keys. The problem is, I can't figure out how to get JDev to g

  • X230: SATA errors with 180GB Intel 520 SSD under heavy write load

    Hi, We spent a couple of days cornering what appears to be an issue with the Intel 520 SSD drives in Lenovo x230 laptops. It was first showing up on a clean Debian installation, while installing a guest operating system into a VM. Looking around on f

  • J1IEX T-Code

    Hi, To post the data for RG23C with multiple Line Items in the J1IEX T-code is it advisable to use LSMW or BDC Program. B'cas through LSMW recording method the Multiple Line Items seems to be impossible to upload, and in BDC some of the screen fields

  • The instruction at"0x10007dba" referenced memory at "0x7c90e514" The memory could not be "written"

    When trying to open firefox receive application error message with ok to terminate and cancel to debug - window then closes & program is unusable. complete error message titled firefox.exe - Application Error The instruction at "0x10007dba" reference

  • Strange droplet behavior

    Hello, I have a few droplets for my common encoding tasks. E.g. MPEG2 or AC3. The strange thing is that when I add more than one file to be encoded (left side) in the same format or choses to encode the file in different formats (right side), I alway