在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
压缩库为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
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论