本文整理匯總了Java中java.lang.Process.destroy方法的典型用法代碼示例。如果您正苦於以下問題:Java Process.destroy方法的具體用法?Java Process.destroy怎麽用?Java Process.destroy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.lang.Process
的用法示例。
在下文中一共展示了Process.destroy方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: destroyProcess
import java.lang.Process; //導入方法依賴的package包/類
/**
* Destroy a Process, first attempting to close its I/O streams.
*
* @param p The Process to destroy
*/
static private void destroyProcess(Process p) {
if (p == null)
return;
InputStream stdout = p.getInputStream();
InputStream stderr = p.getErrorStream();
OutputStream stdin = p.getOutputStream();
try {
if (stdout != null)
stdout.close();
if (stderr != null)
stderr.close();
if (stdin != null)
stdin.close();
}
catch(IOException e) {
e.printStackTrace();
}
p.destroy();
}
示例2: runtool
import java.lang.Process; //導入方法依賴的package包/類
private static void runtool(jvm jvm, String loc, String[] args)
throws IOException
{
System.out.println(concatenate(args) + ':');
if (jvm == null) {
com.pivotal.gemfirexd.internal.iapi.tools.run.main(args);
return;
}
Vector cmd = jvm.getCommandLine();
cmd.addElement("-jar");
cmd.addElement(loc);
for (int i=0; i < args.length; i++) {
cmd.addElement(args[i]);
}
String command = concatenate((String[]) cmd.toArray(new String[0]));
Process pr = null;
try
{
pr = Runtime.getRuntime().exec(command);
BackgroundStreamSaver saver =
new BackgroundStreamSaver(pr.getInputStream(), System.out);
saver.finish();
pr.waitFor();
pr.destroy();
} catch(Throwable t) {
System.out.println("Process exception: " + t.getMessage());
if (pr != null)
{
pr.destroy();
pr = null;
}
}
}
示例3: shut
import java.lang.Process; //導入方法依賴的package包/類
private static void shut(Process proc) {
try {
if (proc != null) {
shut(proc.getInputStream());
shut(proc.getOutputStream());
proc.destroy();
}
} catch (Exception e) {
// just as planned
}
}
示例4: shutdownFast
import java.lang.Process; //導入方法依賴的package包/類
void shutdownFast() {
Process p = child;
if (p != null) {
p.destroy();
}
}
示例5: main
import java.lang.Process; //導入方法依賴的package包/類
public static void main(String[] args){
try
{
int generations;
Scanner a = new Scanner(System.in);
String currentDirectory;
currentDirectory = System.getProperty("user.dir");
System.out.println("Current working directory : "+currentDirectory);
Population pop = new Population();
String[] genArray = new String[16];
System.out.println("how many generations shall we listen to?");
generations = Integer.parseInt(a.next());
for(int i=1; i<=generations; i++){
createFolder("/Users/abraxas/Desktop/brainmusic/gen"+i);
for(int m=0; m<16; m++){
genArray[m]=pop.getBna(m);
}
for(int n=0; n<16; n++){
String c = new String("./muse-player -l 5000 -C gen"+i+"/song"+(n+1)+" -i /muse/elements/delta_absolute /muse/elements/is_good");
Process read = Runtime.getRuntime().exec(c);
MidiConverter.convertToMidi(genArray[n]);
read.destroy();
System.out.println("Created data file gen"+i+"song"+(n+1));
CSVParse parser = new CSVParse("/Users/abraxas/Desktop/brainmusic/gen"+i+"/song"+(n+1));
double temp=parser.parse();
pop.setFitness(n,temp);
}
System.out.println("done gen"+i);
pop = new Population(Selection.select(pop),pop);
}
System.out.println("all done!");
}
catch(Exception e){
System.out.println(e.getMessage());
}
}