(function (inFilePath, outFilePath){
    var File = java.io.File;
    var System = java.lang.System;


    var match;
    var inFile = new File(inFilePath+'/_examples/editor_api.js');
    var html = getStringOfFile(inFile);

    var rootDir = new File(inFilePath+'/_src');
    var arr = html.match(/(\/\/)?'[^']+\.js/gi);


    var buff = [];
    for (var i=0; i<arr.length; i++) {
        var s = arr[i].replace(/'|(\/\/[^.]+\.js)/ig,'');
        if(s!=""){
            System.out.println(s);
            var file = new File(rootDir, s);
        }


        buff.push(getStringOfFile(file));
    }
    var outFile = new File(outFilePath);
    setStringOfFile(outFile, "(function(){"+buff.join('\n')+"})();");


    function getStringOfFile(file){
        var buff = java.lang.reflect.Array.newInstance(
            java.lang.Character.TYPE, file.length());
        try {
            var input = new java.io.InputStreamReader(
                new java.io.BufferedInputStream(
                    new java.io.FileInputStream(file)
                ), 'UTF-8');
            input.read(buff);
        } finally {
            if (input) {
                input.close();
            }
        }
        return String(new java.lang.String(buff)).replace(/\0|\uFEFF/g, '');
    }
    function setStringOfFile(file, str){
        try {
            var output = new java.io.OutputStreamWriter(
                new java.io.BufferedOutputStream(
                    new java.io.FileOutputStream(file)
                ), 'UTF-8');
            output.write(str);
        } finally {
            if (output) {
                output.close();
            }
        }
    }

})(arguments[0], arguments[1]);
