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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 765 jeremybenn
// Verify we can modify the environment.
2
import java.io.BufferedReader;
3
import java.io.InputStream;
4
import java.io.InputStreamReader;
5
import java.util.Map;
6
 
7
 
8
 
9
public class Process_7
10
{
11
  public static void main(String[] args)
12
  {
13
    try
14
      {
15
        ProcessBuilder pb = new ProcessBuilder("env");
16
        Map<String, String> e = pb.environment();
17
        e.clear();
18
        String v = "process7_value";
19
        String k = "PROCESS_7_KEY";
20
        e.put(k, v);
21
        Process p = pb.start();
22
        InputStream is = p.getInputStream();
23
        InputStreamReader isr = new InputStreamReader(is);
24
        BufferedReader br = new BufferedReader(isr);
25
        boolean found = false;
26
 
27
        String result;
28
        while ((result = br.readLine()) != null)
29
          {
30
            if (result.equals(k + '=' + v))
31
              found = true;
32
          }
33
        if (!found)
34
          {
35
            System.out.println("bad");
36
            return;
37
          }
38
        System.out.println("ok");
39
      }
40
    catch (Exception ex)
41
      {
42
        System.out.println(ex.toString());
43
      }
44
  }
45
}

powered by: WebSVN 2.1.0

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