【javascript学习指南】java怎么运行perl?如何在Java中调用Perl脚本?

更新时间:2021-06-03    来源:Perl    手机版     字体:

【www.bbyears.com--Perl】

 代码如下

import java.io.*;  

public class TestExec {  

    public static void main(String[] args) {  

        try {  

            Process p = Runtime.getRuntime().exec("perl script.pl");  

            BufferedReader in = new BufferedReader(  

                                new InputStreamReader(p.getInputStream()));  

            String line = null;  

            while ((line = in.readLine()) != null) {  

                System.out.println(line);  

            }  

        } catch (IOException e) {  

            e.printStackTrace();  

        }  

    }  

}

本文来源:http://www.bbyears.com/jiaocheng/121463.html