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 {
/**
* @param args
*/
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