Mattie

Untitled

Feb 10th, 2011
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1.     public static String oneLine(String cmd)
  2.     {
  3.  
  4.         Runtime run = Runtime.getRuntime();
  5.         Process pr;
  6.         try
  7.         {
  8.             pr = run.exec(cmd);
  9.             pr.waitFor();
  10.             BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream()));
  11.             String line = "";
  12.             while ((line = buf.readLine()) != null)
  13.             {
  14.                 return line;
  15.             }
  16.  
  17.         } catch (IOException e)
  18.         {
  19.             // TODO Auto-generated catch block
  20.             e.printStackTrace();
  21.         } catch (InterruptedException e)
  22.         {
  23.             // TODO Auto-generated catch block
  24.             e.printStackTrace();
  25.         }
  26.  
  27.         return null;
  28.     }
Add Comment
Please, Sign In to add comment