public class Filter
extends java.lang.Object
xxxyyy.pl is a perl script in
the user's working directory that contains
#!perl $_ = <STDIN>; chomp(); printf "xxx %s yyy\n", $_; __END__Then the Java call
Filter f = new Filter("perl xxxyyy.pl");
System.out.println(f.filter("hello world"));
will output
xxx hello world yyy
| Constructor and Description |
|---|
Filter(java.lang.String cmd)
Construct a filter for a given external script.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
filter(java.lang.String input)
Runs an external script on an input string and returns the output string
produced by the script.
|
public Filter(java.lang.String cmd)
cmd - the command used to invoke the script.public java.lang.String filter(java.lang.String input)
throws java.io.IOException,
java.lang.InterruptedException
input - the input string to be processed by the scriptjava.io.IOException - if an I/O error occursjava.lang.InterruptedException - if the process is interrupted by another thread