DecompAllForm

import java.awt.Button;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Label;
import java.awt.List;
import java.awt.TextField;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetAdapter;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class DecompAllForm
{

 private static Label statusLabel = new Label("no start");
 private static List logList = new List();
 private static Thread processThread = null;
 private static ArrayList clzs = new ArrayList();
 private static String src=null;
 private static String destFolder=null;
 private static boolean running=true;
 private static SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss.SSS");
 private static ArrayList supportList = new ArrayList();

 public static void main(String[] args)
 {
  final Frame window = new Frame();
  window.setSize(400, 400);
  window.setLayout(null);
  window.setLocation(480, 320);
  window.setResizable(false);
  //window.setBackground(Color.LIGHT_GRAY);
  window.setTitle("Decompile All - By Wafly");
  window.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e)
  {
   window.dispose();
   System.exit(0);
  }});
  
  Label srcPathLabel = new Label("Source path:");
  srcPathLabel.setSize(100, 20);
  srcPathLabel.setLocation(20, 50);
  window.add(srcPathLabel);
  
  final TextField srcPathInput = new TextField("input the package path or folder path");
  srcPathInput.setSize(260, 20);
  srcPathInput.setLocation(120, 50);
  srcPathInput.addFocusListener(new FocusListener(){
   public void focusGained(FocusEvent arg0)
   {
    srcPathInput.selectAll();
   }
   public void focusLost(FocusEvent arg0) { }
  });
  window.add(srcPathInput);
  
  Label distPathLabel = new Label("Destination path:");
  distPathLabel.setSize(100, 20);
  distPathLabel.setLocation(20, 100);
  window.add(distPathLabel);
  
  final TextField distPathInput = new TextField("input the folder path");
  distPathInput.setSize(260, 20);
  distPathInput.setLocation(120, 100);
  distPathInput.addFocusListener(new FocusListener(){
   public void focusGained(FocusEvent arg0)
   {
    distPathInput.selectAll();
   }
   public void focusLost(FocusEvent arg0) { }
  });
  window.add(distPathInput);
  
  Label statusTitleLabel = new Label("Current status:");
  statusTitleLabel.setSize(100, 20);
  statusTitleLabel.setLocation(20, 150);
  window.add(statusTitleLabel);
  
  statusLabel.setSize(250, 20);
  statusLabel.setLocation(120, 150);
  window.add(statusLabel);
  
  final Button startBtn = new Button("START");
  startBtn.setSize(100, 20);
  startBtn.setLocation(70, 200);
  startBtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent arg0) {
   processThread = new Thread()
   {
    public void run()
    {
     try {
      src = srcPathInput.getText();
      destFolder = distPathInput.getText();
      if(!new File(src).exists())
      {
       statusLabel.setText("Source path/package not exists!");
       return;
      }
      File folder = new File(destFolder);
      if(destFolder.replace("\\", "/").indexOf("/")<0)
      {
       statusLabel.setText("Destination path format not correct!");
       return;
      }
      if(!folder.exists() && !folder.mkdirs())
      {
       statusLabel.setText("Fail to create destination folder!");
       return;
      }
      if(!folder.isDirectory())
      {
       statusLabel.setText("Destination is not a folder!");
       return;
      }
      process();
      statusLabel.setText("Task completed.");
     } catch (Exception e) {
      statusLabel.setText("Error: "+e.getMessage());
      addLog(e.getMessage());
      e.printStackTrace();
     } finally {
      processThread=null;
      startBtn.setEnabled(true);
     }
    }
   };
   startBtn.setEnabled(false);
   logList.removeAll();
   clzs.clear();
   running=true;
   processThread.start();
   statusLabel.setText("Thread started.");
  }});
  window.add(startBtn);
  
  Button stopBtn = new Button("STOP");
  stopBtn.setSize(100, 20);
  stopBtn.setLocation(230, 200);
  stopBtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent arg0) {
   if(processThread==null)
    return;
   try {
    processThread.interrupt();
   } catch (Exception e) {
    e.printStackTrace();
   }
   processThread=null;
   running=false;
   statusLabel.setText("Thread force stopped !!");
   startBtn.setEnabled(true);
  }});
  window.add(stopBtn);
  
  logList.setSize(360, 120);
  logList.setLocation(20, 250);
  window.add(logList);
  
  window.setVisible(true);
  stopBtn.requestFocus();
  
  BufferedReader reader = null;
  try {
   reader = new BufferedReader(new InputStreamReader(new FileInputStream("SupportPkg.list")));
   String fileType = null;
   while((fileType=reader.readLine())!=null)
   {
    supportList.add(fileType);
    addLog("Add support package type: *"+fileType);
   }
   reader.close();
  } catch (Exception e) {
   statusLabel.setText("Error: Fail to load package type.");
   addLog(e.getMessage());
   e.printStackTrace();
  }

  new DropTarget(window, DnDConstants.ACTION_COPY, new DropTargetAdapter() {
    @Override
    public void drop(DropTargetDropEvent event) {
     event.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
     Transferable transferable = event.getTransferable();
     DataFlavor[] flavors = transferable.getTransferDataFlavors();
     try {
      if (flavors[0].equals(DataFlavor.javaFileListFlavor)) {
       File f = (File)((java.util.List) transferable.getTransferData(flavors[0])).get(0);
       srcPathInput.setText(f.getAbsolutePath());
      }
     } catch (Exception e) {
      statusLabel.setText("Fail to locate the source path.");
     }
     event.dropComplete(true);
    }
   });
 }
 
 private static void process() throws Exception
 {
  statusLabel.setText("Unzip package...");
  unzipEARnWARnJARnZIP(src);
  if(new File(src).isFile())
  {
   if(src.substring(src.lastIndexOf(".")).equalsIgnoreCase(".class"))
    clzs.add(src);
   else
    src=src.substring(0, src.lastIndexOf("."));
  }
  statusLabel.setText("Calculating...");
  listFiles(src);
  if(clzs.size()==0)
  {
   throw new Exception("Class file not found.");
  }
  for(int i=0; i<clzs.size() && running; i++)
  {
   statusLabel.setText("Decompiling..."+((i+1)*100/clzs.size())+"% ("+(i+1)+" / "+clzs.size()+")");
   addLog("Decompile "+clzs.get(i));
   try {
    Runtime.getRuntime().exec("jad -o -r -lnc -sjava -d "+destFolder+" "+clzs.get(i));
   } catch (Exception e) {
    statusLabel.setText("Fail to locate the source path.");
   }
  }
 }

 public static void unzipEARnWARnJARnZIP(String path) throws Exception
 {
  if(!running)
   return;
  File parents = new File(path);
  if(parents.isFile())
  {
   String filePath = parents.getAbsolutePath();
   filePath.replace("\\", "/");
   int extIndex = filePath.lastIndexOf(".");
   if(extIndex<1)
    return;
   String fileExt = filePath.substring(extIndex);
   if(supportList.contains(fileExt.toLowerCase()))
   {
    String targetUnzipPath=filePath.substring(0, extIndex);
    
    File targetUnzipPathFile = new File(targetUnzipPath);
    if(targetUnzipPathFile.exists()&&!targetUnzipPathFile.isDirectory())
     throw new Exception("Fail to create target folder ["+targetUnzipPath+"].");
    targetUnzipPathFile.mkdirs();
    addLog("Unzip "+parents.getName());

    try {
     Runtime.getRuntime().exec("winrar x -o+ -inul "+filePath+" "+targetUnzipPath).waitFor();
    } catch (Exception e) {
     e.printStackTrace();
    }
    unzipEARnWARnJARnZIP(targetUnzipPath);
   }
  }
  else if(parents.isDirectory())
  {
   File[] children = parents.listFiles();
   for(int i=0; i<children.length; i++)
    unzipEARnWARnJARnZIP(children[i].getAbsolutePath());
  }
 }
 
 private static void listFiles(String path)
 {
  if(!running)
   return;
  File[] fds = new File(path).listFiles();
  if(fds==null)
   return;
  for(int i=0; i<fds.length; i++)
  {
   if(fds[i].isFile() && fds[i].getName().toLowerCase().endsWith(".class") && fds[i].getName().indexOf("$")<0)
   {
    clzs.add(fds[i].getAbsolutePath());
   }
   else if(fds[i].isDirectory())
    listFiles(fds[i].getAbsolutePath());
  }
 }

 private static void addLog(String log)
 {
  format.format(new Date());
  logList.add("["+format.format(new Date())+"] "+log);
  logList.select(logList.getItemCount()-1);
 }
 
}

基于SpringBoot网上超市,系统包含两种角色:用户、管理员,系统分为前台和后台两大模块,主要功能如下: 1 管理员功能实现 商品信息管理 管理员可以通过提交商品名称查询商品,并查看该商品的用户评论信息。 用户管理 管理员通过提交用户名来获取用户资料,对有异常情况的用户信息进行修改,并可以详细查看用户资料。 商品评价管理 管理员审核用户对商品的评价,经过审核的评价才会显示,并可以统计商品评价信息。 已支付订单 管理员查看已支付的订单,并逐个进行订单发货。 2 用户功能实现 商品信息 用户可以收藏、立即购买商品,或对商品进行评价,同时将商品添加到购物车。 购物车 用户可以直接下单购买购物车中的商品,或删除购物车中的商品。 确认下单 用户选择地址,查看支付金额信息,以确认订单之前的所有细节。 已支付订单 用户查看已支付的订单,若对购买商品产生后悔,可以申请退款。 二、项目技术 开发语言:Java 数据库:MySQL 项目管理工具:Maven Web应用服务器:Tomcat 前端技术:Vue、 后端技术:SpringBoot框架 三、运行环境 操作系统:Windows、macOS都可以 JDK版本:JDK1.8以上版本都可以 开发工具:IDEA、Ecplise都可以 数据库: MySQL 5.7/8.0版本均可 Tomcat:7.x、8.x、9.x版本均可 Maven:任意版本都可以
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值