OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [testsuite/] [libjava.lang/] [Process_1.java] - Blame information for rev 781

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 765 jeremybenn
// Create a process and read from its standard output.
2
//
3
import java.io.BufferedReader;
4
import java.io.InputStream;
5
import java.io.InputStreamReader;
6
 
7
 
8
public class Process_1
9
{
10
  public static void main(String[] args)
11
  {
12
    try
13
      {
14
        Runtime r = Runtime.getRuntime();
15
        String s = "Hello World";
16
        String[] a = { "echo", s };
17
        Process p = r.exec(a);
18
        InputStream is = p.getInputStream();
19
        InputStreamReader isr = new InputStreamReader(is);
20
        BufferedReader br = new BufferedReader(isr);
21
        String result = br.readLine();
22
        if (! s.equals(result))
23
          {
24
            System.out.println("bad 1");
25
            return;
26
          }
27
        result = br.readLine();
28
        if (result != null)
29
          {
30
            System.out.println("bad 2");
31
            return;
32
          }
33
        int c = p.waitFor();
34
        System.out.println(c == 0 ? "ok" : "bad 3");
35
      }
36
    catch (Exception ex)
37
      {
38
        System.out.println(ex.toString());
39
      }
40
  }
41
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.