gcc/libjava/testsuite/libjava.lang/Process_2.java
David Daney faa03cf1b4 Process_1.java: New test.
2004-08-03  David Daney  <ddaney@avtrex.com>

	* testsuite/libjava.lang/Process_1.java: New test.
	* testsuite/libjava.lang/Process_2.java: New test.
	* testsuite/libjava.lang/Process_3.java: New test.
	* testsuite/libjava.lang/Process_4.java: New test.
	* testsuite/libjava.lang/Process_5.java: New test.
	* testsuite/libjava.lang/Process_6.java: New test.
	* testsuite/libjava.lang/Process_1.out: Expected result.
	* testsuite/libjava.lang/Process_2.out: Expected result.
	* testsuite/libjava.lang/Process_3.out: Expected result.
	* testsuite/libjava.lang/Process_4.out: Expected result.
	* testsuite/libjava.lang/Process_5.out: Expected result.
	* testsuite/libjava.lang/Process_6.out: Expected result.

From-SVN: r85881
2004-08-12 16:24:56 +00:00

41 lines
885 B
Java

// Create a process and read from its standard error.
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
public class Process_2
{
public static void main(String[] args)
{
try
{
Runtime r = Runtime.getRuntime();
String s = "Hello World";
String[] a = { "sh", "-c", "echo " + s + " >&2" };
Process p = r.exec(a);
InputStream is = p.getErrorStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String result = br.readLine();
if (! s.equals(result))
{
System.out.println("bad 1");
return;
}
result = br.readLine();
if (result != null)
{
System.out.println("bad 2");
return;
}
int c = p.waitFor();
System.out.println(c == 0 ? "ok" : "bad 3");
}
catch (Exception ex)
{
System.out.println(ex.toString());
}
}
}