• C#调用jar包压缩js


    压缩库为google提供的 Closure Compiler

    https://developers.google.com/closure/compiler/?hl=zh-cn

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Diagnostics;
    
    namespace TestProcessDosCmd
    {
        class Program
        {
            static void Main(string[] args)
            {
    
                Process p = null;
                p = new Process();
                
                p.StartInfo.FileName = "cmd.exe";
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardInput = true;
                p.StartInfo.RedirectStandardOutput = false;
                p.StartInfo.RedirectStandardError = false;
                p.StartInfo.CreateNoWindow = false;
                p.Start();
    
                String sResult = string.Empty;
                string strCmd = "java -jar compiler.jar --help";
    
                //string strCmd = @"java -jar compiler.jar --js D:\DevSoft\Library\compiler-latest\js_name.js --js_output_file D:\DevSoft\Library\compiler-latest\js_name_compressed_prog.js";
    
                //不能源文件与目的文件放同一位置
                //string strCmd = @"java -jar compiler.jar --js D:\DevSoft\Library\compiler-latest\js_name_bak.js --js_output_file D:\DevSoft\Library\compiler-latest\js_name_bak.js";
                
                //string strCmd = "java -version";
                p.StandardInput.WriteLine(strCmd);
               
    
                //while (!p.StandardError.EndOfStream)
                //{
                //    sResult = p.StandardError.ReadLine();
                //    Console.WriteLine(sResult);
                //}
    
                //p.StandardInput.Flush();
    
                //while (!p.StandardOutput.EndOfStream)
                //{
                //    sResult = p.StandardOutput.ReadLine();
                //    Console.WriteLine(sResult);
                //}
                
                p.StandardInput.WriteLine("exit");
    
                p.WaitForExit();
                p.Close();
    
                Console.WriteLine("Press Any Key to exit.");
                Console.ReadKey();
            }
        }
    }
    

      

    from: https://developers.google.com/closure/compiler/docs/api-tutorial1?hl=zh-cn

    #!/usr/bin/python2.4
    
    import httplib, urllib, sys
    
    # Define the parameters for the POST request and encode them in
    # a URL-safe format.
    
    params = urllib.urlencode([
        ('js_code', sys.argv[1]),
        ('compilation_level', 'WHITESPACE_ONLY'),
        ('output_format', 'text'),
        ('output_info', 'compiled_code'),
      ])
    
    # Always use the following value for the Content-type header.
    headers = { "Content-type": "application/x-www-form-urlencoded" }
    conn = httplib.HTTPConnection('closure-compiler.appspot.com')
    conn.request('POST', '/compile', params, headers)
    response = conn.getresponse()
    data = response.read()
    print data
    conn.close
    

      

  • 相关阅读:
    POJ3122贪心或者二分(分蛋糕)
    POJ2118基础矩阵快速幂
    POJ2118基础矩阵快速幂
    POJ1328贪心放雷达
    POJ1328贪心放雷达
    hdu4642博弈(矩阵)
    hdu4642博弈(矩阵)
    POJ1042 贪心钓鱼
    POJ3160强连通+spfa最长路(不错)
    POJ3114强连通+spfa
  • 原文地址:https://www.cnblogs.com/wucg/p/2399980.html
Copyright © 2020-2023  润新知