perl
来源:互联网 发布:西语记单词软件 编辑:程序博客网 时间:2024/06/08 12:03
代码亲自跑一下,很好玩
Java 调用 perl
- Runtime.getRuntime().exec("perl C:\\Perl\\execise.pl");
Java 调用 perl 通过IO的方式来得到返回值
- package fiveGame;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- public class JavaCallPerl {
- public static void main(String[] args) throws IOException {
- StringBuffer resultStringBuffer = new StringBuffer();
- String lineToRead = "";
- int exitValue = 0;
- try {
- Process proc = Runtime.getRuntime().exec("perl C:\\Perl\\execise.pl");
- InputStream inputStream = proc.getInputStream();
- BufferedReader bufferedRreader = new BufferedReader(new InputStreamReader(inputStream));
- // save first line
- if ((lineToRead = bufferedRreader.readLine()) != null) {
- resultStringBuffer.append(lineToRead);
- }
- // save next lines
- while ((lineToRead = bufferedRreader.readLine()) != null) {
- resultStringBuffer.append("\r\n");
- resultStringBuffer.append(lineToRead);
- }
- // Always reading STDOUT first, then STDERR, exitValue last
- proc.waitFor(); // wait for reading STDOUT and STDERR over
- exitValue = proc.exitValue();
- } catch (Exception ex) {
- resultStringBuffer = new StringBuffer("");
- exitValue = 2;
- }
- System.out.println("exit:" + exitValue);
- System.out.println(resultStringBuffer.toString());
- }
- }
perl
- #!/usr/bin/perl -w
- $pi = 3.141592654;
- $circ = 2 * $pi * 12.5;
- print "The circumference of a circle of radius 12.5 is $circ.\n";
1 0
- perl
- Perl
- perl
- perl
- Perl
- perl
- perl
- perl
- Perl
- perl
- perl
- perl
- perl
- perl
- Perl
- perl
- Perl
- perl
- A.4输入圆柱体的半径r和高h,输出圆柱体的表面积s
- Linux JDK 以及 tomcat 的安装和配置
- 多个IP快速切换设置—win7
- 《程序员的呐喊》阅读
- Spring MVC 学习指南学习,学习笔记。
- perl
- JavaScript实现原生ajax
- Perl 模块 Getopt::Std 和 Getopt::Long
- perl模块Getopt::Std用法及实例-从命令行读取参数模块
- Unity3D 四元数旋转使用 Quaternion
- 第一天来认识认识指针与const
- PYTHON中的语法元素(续)--Python(8)
- JavaScript取数组数据动态生成下拉列表
- VMware Workstation 12 Pro