public final class Utils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
copyURLToFile(org.fuin.utils4swing.progress.FileCopyProgressListener listener,
URL srcFileUrl,
File destFile,
int fileNo,
int fileSize)
Copies a file from an URL to a local destination.
|
static void |
copyURLToFile(String url,
File file)
Copies bytes from the URL source to a file destination.
|
static String |
escapeXml(String str)
Escapes the five basic XML entities (gt, lt, quot, amp, apos).
|
static void |
main(String[] args)
Main method to test the monitor.
|
static boolean |
nullSafeEquals(Object obj1,
Object obj2)
Compares two objects with their equals(..) method in a
null
safe way. |
static void |
unzip(org.fuin.utils4swing.progress.FileCopyProgressListener listener,
File zipFile,
int zipFileNo,
File destDir,
org.fuin.utils4j.Cancelable cancelable)
Unzips a file into a local directory.
|
public static void copyURLToFile(org.fuin.utils4swing.progress.FileCopyProgressListener listener,
URL srcFileUrl,
File destFile,
int fileNo,
int fileSize)
throws FileNotFoundException
IOExceptions are mapped into a RuntimeException
.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.FileNotFoundException - The srcFileUrl was not found.public static void unzip(org.fuin.utils4swing.progress.FileCopyProgressListener listener,
File zipFile,
int zipFileNo,
File destDir,
org.fuin.utils4j.Cancelable cancelable)
IOExceptions are mapped into
a RuntimeException .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.public static void copyURLToFile(String url, File file)
IOExceptions are wrapped into RuntimeException.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.public static final String escapeXml(String str)
str - Text to escape or null.null if argument was
null.public static boolean nullSafeEquals(Object obj1, Object obj2)
null
safe way.obj1 - First object or null.obj2 - First object or null.true else
false.public static void main(String[] args)
args - Not used.Copyright © 2013 Future Invent Informationsmanagement GmbH, Hamburg (Germany). All Rights Reserved.