當前位置: 首頁>>代碼示例>>Java>>正文


Java Process.destroy方法代碼示例

本文整理匯總了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();
}
 
開發者ID:CA-IRIS,項目名稱:ca-iris,代碼行數:25,代碼來源:OSUtils.java

示例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;
        }
    }
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:38,代碼來源:derbyrunjartest.java

示例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
    }
}
 
開發者ID:chdir,項目名稱:fdshare,代碼行數:12,代碼來源:FileDescriptorFactory.java

示例4: shutdownFast

import java.lang.Process; //導入方法依賴的package包/類
void shutdownFast() {
    Process p = child;
    if (p != null) {
        p.destroy();
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:7,代碼來源:Activation.java

示例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());
 
  }
     
}
 
開發者ID:naomi-,項目名稱:brain-beats,代碼行數:50,代碼來源:brainmusic.java


注:本文中的java.lang.Process.destroy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。