ObfuscateJS API
Instead of using the command-line utility, you can also call ObfuscateJS directly from your Java application. A simple example is given below.Methods
The com.twovi.tools.js.Obfuscator class has two methods for obfuscation:
public static void obfuscate(File inFile, File outFile)throws IOException
public static void obfuscate(File inFile, File outFile, String prefix) throws IOException
Example
import com.twovi.tools.js.Obfuscator;
import java.io.*;
public class MyObfuscator{
public static void main(String[] args){
try{
File inFile = new File(args[0]);
File outFile = new File(args[1]);
Obfuscator.obfuscate(inFile, outFile);
}catch(IOException e){
e.printStackTrace();
System.exit(0);
}
}
}