2011-06-09 17 views

cevap

73

He're ne buldum:

import java.io.ByteArrayOutputStream; 
import org.apache.commons.exec.CommandLine; 
import org.apache.commons.exec.DefaultExecutor; 
import org.apache.commons.exec.Executor; 
import org.apache.commons.exec.PumpStreamHandler; 

public String execToString(String command) throws Exception { 
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 
    CommandLine commandline = CommandLine.parse(command); 
    DefaultExecutor exec = new DefaultExecutor(); 
    PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream); 
    exec.setStreamHandler(streamHandler); 
    exec.execute(commandline); 
    return(outputStream.toString()); 
} 
+1

çok teşekkür ederim –

İlgili konular