How to programmatically search for a file inside some JAR into java?

Java: Copy jar files programmatically into another destination.

I have a simple solution is like below:

What is jar file?

Jar is a collection of a multiple files as single one file. Jar files are an better way to distribute java application.It is compressing a file into a zip file is an better way to distribute other program over the internet.

To start JAR file just type the below command.

java -jar example.jar

To explode or extract the JAR file type the below command.

jar -xf example.jar

Now how to search jar files programmatically into another destination?

=>You just use JarInputStream to open it.
=>Then over it using getNextJarEntry.
=>Finaly compare name using ZipEntry.getName().

Your jar file has been search programmatically.

About the Author

avatar