使用runtime类执行dos命令并且解析输出结果

import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Test { private static final Pattern p = Pattern .compile("(UU|D|U|_U)//s+(//S+?//.jsp)"); /** * @param args */ public static void main(String[] args) throws Exception { Process process = Runtime.getRuntime().exec( "svnlook changed -r 15 F://svn//svnrepos"); BufferedReader reader = new BufferedReader(new InputStreamReader( process.getInputStream())); String line = null; while ((line = reader.readLine()) != null) { Matcher m = p.matcher(line); if (m.matches()) { System.out.println(m.group(2)); } else { System.out.println("unmatch"); } } reader.close(); } }

你可能感兴趣的:(使用runtime类执行dos命令并且解析输出结果)