In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you how to decompress jar, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Scene
Upload the jar package on the page
Extract the jar package in the background
The page shows all the package
Select a package
The page displays class and sub-package
Select class to go to the class parsing page
Select package to display class and sub-package
Decompress jarpackage com.wuxiongwei.java.jar2;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.nio.ByteBuffer;import java.nio.channels.Channels;import java.nio.channels.FileChannel;import java.nio.channels.ReadableByteChannel;import java.util.Enumeration;import java.util.jar.JarEntry;import java.util.jar.JarFile / * very good tool class
* decompress jar. * @ author * @ version 1.0.0 * / public class JarDecompression {protected static Log log = LogFactory.getLog (JarDecompression.class); @ SuppressWarnings ("resource") public static void uncompress (File jarFile, File tarDir) throws IOException {JarFile jfInst = new JarFile (jarFile); Enumeration enumEntry = jfInst.entries (); while (enumEntry.hasMoreElements ()) {JarEntry jarEntry = (JarEntry) enumEntry.nextElement () File tarFile = new File (tarDir, jarEntry.getName ()); if (jarEntry.getName (). Contains ("META-INF")) {File miFile = new File (tarDir, "META-INF"); if (! miFile.exists ()) {miFile.mkdirs ();}} makeFile (jarEntry, tarFile) If (jarEntry.isDirectory ()) {continue;} FileChannel fileChannel = new FileOutputStream (tarFile). GetChannel (); InputStream ins = jfInst.getInputStream (jarEntry); transferStream (ins, fileChannel) }} / * Stream switching operation * @ param ins input stream * @ param channel output stream * / private static void transferStream (InputStream ins, FileChannel channel) {ByteBuffer byteBuffer = ByteBuffer.allocate (1024 * 10); ReadableByteChannel rbcInst = Channels.newChannel (ins) Try {while (- 1! = (rbcInst.read (byteBuffer) {byteBuffer.flip (); channel.write (byteBuffer); byteBuffer.clear ();}} catch (IOException ioe) {ioe.printStackTrace () } finally {if (null! = rbcInst) {try {rbcInst.close ();} catch (IOException e) {e.printStackTrace () }} if (null! = channel) {try {channel.close ();} catch (IOException e) {e.printStackTrace () }} / * print jar file content information * @ param file jar file * / public static void printJarEntry (File file) {JarFile jfInst = null;; try {jfInst = new JarFile (file);} catch (IOException e) {e.printStackTrace () } Enumeration enumEntry = jfInst.entries (); while (enumEntry.hasMoreElements ()) {log.info ((enumEntry.nextElement () }} / * create file * @ param jarEntry jar entity * @ param fileInst file entity * @ throws IOException throws an exception * / public static void makeFile (JarEntry jarEntry, File fileInst) {if (! fileInst.exists ()) {if (jarEntry.isDirectory ()) {fileInst.mkdirs () } else {try {fileInst.createNewFile ();} catch (IOException e) {log.error ("failed to create file >" .concat (fileInst.getPath () }} public static void main (String [] args) {File jarFile = new File ("/ Users/mac/Documents/other/bw2/bopsdk-openapi-1.0.2-Release.jar"); File targetDir = new File ("/ Users/mac/Documents/other/bw2/test/"); try {JarDecompression.uncompress (jarFile, targetDir) } catch (IOException e) {e.printStackTrace ();} this is the end of sharing about how to decompress jar. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.