mardi 5 mai 2015

can't read from linux terminal in java

I’m trying to change directory and then execute second process in java but I'm unable to read from terminal. Any ideas ? Thanks in advance. Here is my code :

     Process p, r ;
     String coke = "/home/kdiri/Desktop/TEZ/kemal/RDF/";
     String abc= "/bin/bash cd"+" "+coke;
     r = Runtime.getRuntime().exec(abc);
     try
     {
       r.waitFor();
     }
     catch(InterruptedException ire)
     {}
    BufferedReader br;
    String co = "grep -c bike * | grep -v :0";
    p = Runtime.getRuntime().exec(co);
    br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    p.waitFor();

    String s;
    while ((s = br.readLine()) != null) {
    System.out.println(s);
    }

Aucun commentaire:

Enregistrer un commentaire