org.fuin.kickstart4j
Class Utils

java.lang.Object
  extended by org.fuin.kickstart4j.Utils

public final class Utils
extends java.lang.Object

Utilities for the package.


Method Summary
static void copyURLToFile(org.fuin.utils4swing.progress.FileCopyProgressListener listener, java.net.URL srcFileUrl, java.io.File destFile, int fileNo, int fileSize)
          Copies a file from an URL to a local destination.
static void copyURLToFile(java.lang.String url, java.io.File file)
          Copies bytes from the URL source to a file destination.
static void main(java.lang.String[] args)
          Main method to test the monitor.
static void unzip(org.fuin.utils4swing.progress.FileCopyProgressListener listener, java.io.File zipFile, int zipFileNo, java.io.File destDir, org.fuin.utils4j.Cancelable cancelable)
          Unzips a file into a local directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

copyURLToFile

public static void copyURLToFile(org.fuin.utils4swing.progress.FileCopyProgressListener listener,
                                 java.net.URL srcFileUrl,
                                 java.io.File destFile,
                                 int fileNo,
                                 int fileSize)
                          throws java.io.FileNotFoundException
Copies a file from an URL to a local destination. IOExceptions are mapped into a RuntimeException .

Parameters:
listener - Monitor to use - Can be null if no progress information is needed.
srcFileUrl - Source file URL.
destFile - Destination file.
fileNo - Number of the current file.
fileSize - File size.
Throws:
java.io.FileNotFoundException - The srcFileUrl was not found.

unzip

public static void unzip(org.fuin.utils4swing.progress.FileCopyProgressListener listener,
                         java.io.File zipFile,
                         int zipFileNo,
                         java.io.File destDir,
                         org.fuin.utils4j.Cancelable cancelable)
Unzips a file into a local directory. WARNING: Only relative path entries are allowed inside the archive! IOExceptions are mapped into a RuntimeException .

Parameters:
listener - Listener to inform - Can be null if no progress information is needed.
zipFile - Source ZIP file - Cannot be null and must be a valid ZIP file.
zipFileNo - Number of the zip file.
destDir - Destination directory - Cannot be null and must exist.
cancelable - Signals if the unzip should be canceled - Can be null if no cancel option is required.

copyURLToFile

public static void copyURLToFile(java.lang.String url,
                                 java.io.File file)
Copies bytes from the URL source to a file destination. The directories up to destination will be created if they don't already exist. destination will be overwritten if it already exists. Possible IOExceptions are wrapped into RuntimeException.

Parameters:
url - The URL to copy bytes from, must not be null. A possible MalformedURLException when converting this argument into an URL is wrapped into a RuntimeException.
file - The non-directory File to write bytes to (possibly overwriting), must not be null.

main

public static void main(java.lang.String[] args)
Main method to test the monitor. Only for testing purposes.

Parameters:
args - Not used.


Copyright © 2009 Future Invent Informationsmanagement GmbH. All Rights Reserved.