Example #1
0
  public static String CreateZip(String[] filesToZip, String zipFileName) {

    byte[] buffer = new byte[18024];

    try {

      ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFileName));
      out.setLevel(Deflater.BEST_COMPRESSION);
      for (int i = 0; i < filesToZip.length; i++) {
        FileInputStream in = new FileInputStream(filesToZip[i]);
        String fileName = null;
        for (int X = filesToZip[i].length() - 1; X >= 0; X--) {
          if (filesToZip[i].charAt(X) == '\\' || filesToZip[i].charAt(X) == '/') {
            fileName = filesToZip[i].substring(X + 1);
            break;
          } else if (X == 0) fileName = filesToZip[i];
        }
        out.putNextEntry(new ZipEntry(fileName));
        int len;
        while ((len = in.read(buffer)) > 0) out.write(buffer, 0, len);
        out.closeEntry();
        in.close();
      }
      out.close();
    } catch (IllegalArgumentException e) {
      return "Failed to create zip: " + e.toString();
    } catch (FileNotFoundException e) {
      return "Failed to create zip: " + e.toString();
    } catch (IOException e) {
      return "Failed to create zip: " + e.toString();
    }
    return "Success";
  }
Example #2
0
  // This is f*****g stupid as hell; if this method makes it into a release, somebody shoot me in
  // the head.
  public void delayTap1(int channel, int volume) {

    try {
      InputStream file_input_stream = p.createInput(modpath);
      delayplayerA = new Player(interpolation);

      delayplayerA.set_module(Player.load_module(file_input_stream));
      file_input_stream.close();
      delayplayerA.set_loop(true);
      delayplayerA.receivebuffer(buffersize);

      for (int i = 0; i < delayplayerA.get_num_channels(); i++) {
        if (i != channel) {
          delayplayerA.ibxm.chanmute[i] = true;
        }
      }
      delayplayerA.ibxm.channels[channel].chanvol_override = volume;

      delayplayerA.play();
    } catch (IllegalArgumentException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (LineUnavailableException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
 public int luaCB_text(Lua l, LuaPlugin plugin) {
   try {
     plugin.generateLuaClass(l, new TextOutFile(plugin, object));
   } catch (IOException e) {
     l.pushNil();
     l.pushString("IOException: " + e.getMessage());
     return 2;
   } catch (IllegalArgumentException e) {
     l.pushNil();
     l.pushString("Illegal argument: " + e.getMessage());
     return 2;
   }
   return 1;
 }
 public int luaCB_deflate(Lua l, LuaPlugin plugin) {
   try {
     plugin.generateLuaClass(l, new BinaryOutFile(plugin, new DeflaterOutputStream(object)));
   } catch (IOException e) {
     l.pushNil();
     l.pushString("IOException: " + e.getMessage());
     return 2;
   } catch (IllegalArgumentException e) {
     l.pushNil();
     l.pushString("Illegal argument: " + e.getMessage());
     return 2;
   }
   return 1;
 }
 public int luaCB_four_to_five(Lua l, LuaPlugin plugin) {
   try {
     plugin.generateLuaClass(l, new BinaryOutFile(plugin, new FourToFiveEncoder(object)));
   } catch (IOException e) {
     l.pushNil();
     l.pushString("IOException: " + e.getMessage());
     return 2;
   } catch (IllegalArgumentException e) {
     l.pushNil();
     l.pushString("Illegal argument: " + e.getMessage());
     return 2;
   }
   return 1;
 }
 public static int luaCB_open(Lua l, LuaPlugin plugin) {
   l.pushNil();
   String name = l.checkString(1);
   try {
     plugin.generateLuaClass(l, new BinaryOutFile(plugin, new FileOutputStream(name)));
   } catch (IOException e) {
     l.pushNil();
     l.pushString("IOException: " + e.getMessage());
     return 2;
   } catch (IllegalArgumentException e) {
     l.pushNil();
     l.pushString("Illegal argument: " + e.getMessage());
     return 2;
   }
   return 1;
 }