⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 runtime.java

📁 Learning automata Crawler
💻 JAVA
字号:
import java.io.*;

public class runtime {

	public void run(String cmd)
	{      
	    try
	    {            
	        FileOutputStream fos = new FileOutputStream("output.txt");
	        Runtime rt = Runtime.getRuntime();
	        Process proc = rt.exec(cmd);
	        // any error message?
	        StreamGobbler errorGobbler = new 
	            StreamGobbler(proc.getErrorStream(), "ERROR");            
	        
	        // any output?
	        StreamGobbler outputGobbler = new 
	            StreamGobbler(proc.getInputStream(), "OUTPUT", fos);
	            
	        // kick them off
	        errorGobbler.start();
	        outputGobbler.start();
	                                
	        // any error???
	        int exitVal = proc.waitFor();
	        System.out.println("ExitValue: " + exitVal);
	        fos.flush();
	        fos.close();        
	    } 
	    catch (Throwable t)
	      {
	        t.printStackTrace();
	      }
	}


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -