天天看點

java内調用perl、python、dll、cmd

JAVA調用perl:

package java_perl;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

public class Java_Perl {

public static void main(String[] args) {

System.out.print(execPerl("D:\\workspace\\PerlDemo\\subroutine_10.pl"));

}

private static String execPerl(String fileName){

String cmd = "";

String msg = "";

String brs = "";

cmd = "perl " + fileName;

try {

Process pro = Runtime.getRuntime().exec(cmd);

InputStream ins = pro.getInputStream();

BufferedReader br = new BufferedReader(new InputStreamReader(ins));

while((brs = br.readLine()) != null){

msg += brs;

}

} catch (IOException e) {

e.printStackTrace();

}

return msg;

}

}

//perl程式 subroutine_10.pl

use strict;

sub division{

return $_[0]/$_[1] ;

}

my $result = division 24,2 ;#可以省略&号

print "$result\n";

JAVA調用PYTHON:

http://blog.csdn.net/anbo724/article/details/6608632

JAVA調用DLL

????

JAVA調用cmd、bat

http://www.cnblogs.com/xwdreamer/archive/2011/12/12/2296911.html

轉載于:https://www.cnblogs.com/bluers/archive/2013/01/15/2861126.html