|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opensourcephysics.tools.JarTool
public class JarTool
This provides a simple way to package files in a single JAR or ZIP file
Field Summary | |
---|---|
static int |
NO
|
static int |
NO_TO_ALL
|
static int |
YES
|
static int |
YES_TO_ALL
|
Method Summary | |
---|---|
static void |
alwaysOverwrite()
Sets the overwrite feature to true. |
java.io.File |
append(java.util.ArrayList<java.lang.String> sources,
java.io.File parent,
java.lang.String target)
Appends to an existing compressed file the list of contents provided. |
static boolean |
compress(java.util.ArrayList<java.io.File> sources,
java.io.File target,
java.util.jar.Manifest manifest)
Compresses a list of files and/or directories into a single JAR or ZIP file. |
static boolean |
compress(java.io.File source,
java.io.File target,
java.util.jar.Manifest manifest)
Compresses a directory into a single JAR or ZIP file. |
static int |
confirmOverwrite(java.lang.String filename)
Whether to overwrite an existing file. |
static boolean |
copy(java.io.File source,
java.io.File target)
Copies a file. |
java.io.File |
create(java.util.ArrayList<java.lang.String> sources,
java.io.File parent,
java.io.File target,
java.util.jar.Manifest manifest)
Creates a JAR file out of the list of contents provided. |
static java.util.jar.Manifest |
createManifest(java.lang.String classpath,
java.lang.String mainclass)
Creates a Manifest for a JAR file with the given parameters |
static void |
disableWarning()
This method is kept for backwards compatibility. |
static java.io.File |
extract(java.lang.ClassLoader classLoader,
java.lang.String filename,
java.io.File target)
Extracts a file using the given class loader |
static java.io.File |
extract(java.io.File source,
java.lang.String filename,
java.io.File target)
Extracts a given file from a compressed (ZIP or JAR) file Extensive changes by D Brown 2007-10-31 |
static java.io.File |
extract(java.io.File source,
java.lang.String filename,
java.lang.String destination)
Extracts a given file from a compressed (ZIP or JAR) file |
static boolean |
extract(java.lang.Object source,
java.util.List<?> files,
java.io.File targetDirectory)
Extract a list of files (given by their relative names) to the given target directory. |
static java.io.File |
extract(java.lang.String filename,
java.io.File target)
Extracts a file using the ResourceLoader utility |
static java.util.Collection<java.io.File> |
getContents(java.io.File directory)
Returns all the files under a given directory |
static java.util.jar.Manifest |
getManifest(java.io.File file)
Gets the Manifest of an existing JAR file |
static java.lang.String |
getString(java.lang.String key)
|
static JarTool |
getTool()
Gets the shared JarTool. |
static void |
neverOverwrite()
Sets the overwrite feature to false. |
static boolean |
remove(java.io.File directory)
Completely removes a directory (without warning!) |
void |
run()
|
void |
send(Job job,
Tool replyTo)
Sends a job to this tool and specifies a tool to reply to. |
static void |
setLocale(java.util.Locale locale)
|
static void |
setOwnerFrame(java.awt.Frame owner)
Sets the owner frame for progress dialogs that may appear when creating a JAR file. |
static boolean |
unzip(java.io.File source,
java.io.File targetDirectory)
Uncompresses a ZIP or JAR file into a given directory. |
static boolean |
unzipNoOverwrite(java.io.File source,
java.io.File targetDirectory)
Uncompresses a ZIP or JAR file into a given directory. |
static boolean |
unzipWithAWarning(java.io.File source,
java.io.File targetDirectory)
Uncompresses a ZIP or JAR file into a given directory. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int YES
public static final int NO
public static final int YES_TO_ALL
public static final int NO_TO_ALL
Method Detail |
---|
public static void setLocale(java.util.Locale locale)
public static java.lang.String getString(java.lang.String key)
public static JarTool getTool()
public void run()
run
in interface java.lang.Runnable
public void send(Job job, Tool replyTo) throws java.rmi.RemoteException
send
in interface Tool
job
- the JobreplyTo
- the tool to notify when the job is complete (may be null)
java.rmi.RemoteException
public static void disableWarning()
public static void neverOverwrite()
alwayOverwrite
public static void alwaysOverwrite()
neverOverwrite
public static void setOwnerFrame(java.awt.Frame owner)
owner
- Framepublic java.io.File create(java.util.ArrayList<java.lang.String> sources, java.io.File parent, java.io.File target, java.util.jar.Manifest manifest)
sources
- ArrayList The list of content files to add.
Each item in the list is a String with the relative name of a
file or directory under the given parent directory, or of
a compressed file anywhere in the hard disk.parent
- File The parent directory for all relative filenamestarget
- File The target compressed file.
Its name must ends either in .zip or .jar.
The user will be prompted to confirm the target.manifest
- Manifest A manifest for the newly created JAR file.
Manifest
public java.io.File append(java.util.ArrayList<java.lang.String> sources, java.io.File parent, java.lang.String target)
sources
- ArrayList The list of content files to add.
Each item in the list is a String with the relative name of a
file or directory under the current parent directory, or of
a compressed file anywhere in the hard disk.parent
- File The parent directory for all relative filenamestarget
- String The name of an existing compressed file, relative
to the parent directory.public static java.util.jar.Manifest createManifest(java.lang.String classpath, java.lang.String mainclass)
classpath
- Stringmainclass
- String
public static java.util.jar.Manifest getManifest(java.io.File file)
file
- File the jar file from which to obtain the manifest
public static java.io.File extract(java.io.File source, java.lang.String filename, java.lang.String destination)
source
- File The compressed file to extract the file fromfilename
- String The path of the file to extractdestination
- String The full (or relative to whatever the current
user directory is) path where to save the extracted file
public static java.io.File extract(java.io.File source, java.lang.String filename, java.io.File target)
source
- File The compressed file to extract the file fromfilename
- String The path of the file to extracttarget
- File The target file for the extracted file
public static java.io.File extract(java.lang.ClassLoader classLoader, java.lang.String filename, java.io.File target)
_classLoader
- ClassLoader The class loader to extract the files fromfilename
- String The path of the file to extracttarget
- File The target file for the extracted file
public static java.io.File extract(java.lang.String filename, java.io.File target)
filename
- String The path of the file to extracttarget
- File The target file for the extracted file
public static boolean extract(java.lang.Object source, java.util.List<?> files, java.io.File targetDirectory)
source
- Object Either a compressed java.io.File with the given resources,
a ClassLoader object which will be used to extract the files, or null, in which case,
the ResourceLoader will be used.files
- AbstractList The list of String with the relative names of the files to extracttargetDirectory
- File The target directory where to extract the files
public static boolean copy(java.io.File source, java.io.File target)
source
- File The file to copytarget
- File destination file
public static boolean compress(java.io.File source, java.io.File target, java.util.jar.Manifest manifest)
source
- File The directory to compresstarget
- File The output filemanifest
- Manifest The manifest (in case of a JAR file)
public static boolean compress(java.util.ArrayList<java.io.File> sources, java.io.File target, java.util.jar.Manifest manifest)
sources
- ArrayList The list of files or directories to compresstarget
- File The output filemanifest
- Manifest The manifest (in case of a JAR file)
public static boolean remove(java.io.File directory)
directory
- File The directory to deletepublic static java.util.Collection<java.io.File> getContents(java.io.File directory)
directory
- File
public static boolean unzip(java.io.File source, java.io.File targetDirectory)
source
- File The compressed file to uncompresstargetDirectory
- File The target directory
unzipNoOverwrite
,
unzipWithAWarning
public static boolean unzipNoOverwrite(java.io.File source, java.io.File targetDirectory)
source
- File The compressed file to uncompresstargetDirectory
- File The target directory
unzip
,
unzipWithAWarning
public static boolean unzipWithAWarning(java.io.File source, java.io.File targetDirectory)
source
- File The compressed file to uncompresstargetDirectory
- File The target directory
unzip
,
unzipNoOverwrite
public static int confirmOverwrite(java.lang.String filename)
file
- File
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |