oms3.util.ProcessExecution Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of oms Show documentation
Show all versions of oms Show documentation
Object Modeling System (OMS) is a pure Java object-oriented framework.
OMS v3.+ is a highly interoperable and lightweight modeling framework for component-based model and simulation development on multiple platforms.
/*
* $Id: ProcessExecution.java 7cba5ba59d73 2018-11-29 [email protected] $
*
* This file is part of the Object Modeling System (OMS),
* 2007-2012, Olaf David and others, Colorado State University.
*
* OMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 2.1.
*
* OMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OMS. If not, see .
*/
package oms3.util;
/*
* ProcessExec.java
*
* Created on February 6, 2007, 8:52 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in th
*/
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* ProcessExcecution. Helper class to execute external programs.
*
* @author od
*/
public class ProcessExecution {
ProcessBuilder pb = new ProcessBuilder();
File executable;
Object[] args = new Object[]{};
Logger logger;
//
Writer stderr = new OutputStreamWriter(System.err) {
@Override
public void close() throws IOException {
System.err.flush();
}
};
//
Writer stdout = new OutputStreamWriter(System.out) {
@Override
public void close() throws IOException {
System.out.flush();
}
};
/**
* Null Writer for doing nothing.
*/
public static class NullWriter extends Writer {
@Override
public void close() throws IOException {
}
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
}
@Override
public void flush() throws IOException {
}
}
/**
* Create a new ProcessExecution.
*
* @param executable the executable file.
*/
public ProcessExecution(File executable) {
this.executable = executable;
}
/**
* Set the execution arguments.
*
* @param args the command line arguments
*/
public void setArguments(Object... args) {
this.args = args;
}
/**
* Set the execution arguments.
*
* @param args the program arguments.
*/
public void setArguments(List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy