当前位置: 首页>>代码示例>>Java>>正文


Java EnvironmentUtils.toStrings方法代码示例

本文整理汇总了Java中org.apache.commons.exec.environment.EnvironmentUtils.toStrings方法的典型用法代码示例。如果您正苦于以下问题:Java EnvironmentUtils.toStrings方法的具体用法?Java EnvironmentUtils.toStrings怎么用?Java EnvironmentUtils.toStrings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.exec.environment.EnvironmentUtils的用法示例。


在下文中一共展示了EnvironmentUtils.toStrings方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: launch

import org.apache.commons.exec.environment.EnvironmentUtils; //导入方法依赖的package包/类
/**
 * Creates a process with an array of arguments. It seems to be the only
 * safe way to create a process with arguments containing spaces. The
 * implementation of {@link Runtime#exec(String, String[], File)} doesn't
 * appear to process single or double quotes when tokenizing a
 * command-line.
 * 
 * @see Runtime#exec(String[], String[], File)
 */
@Override
protected Process launch(CommandLine commandLine, @SuppressWarnings("rawtypes") Map environment,
		File workingDirectory) throws IOException {

	if (workingDirectory != null && !workingDirectory.exists()) {
		throw new IOException(workingDirectory + " doesn't exist.");
	}

	String[] envVars = EnvironmentUtils.toStrings(environment);
	String[] arguments = commandLine.getArguments();
	String[] command = new String[arguments.length + 1];
	
	command[0] = commandLine.getExecutable();
	System.arraycopy(arguments, 0, command, 1, arguments.length);

	return Runtime.getRuntime().exec(command, envVars, workingDirectory);
}
 
开发者ID:Zenika,项目名称:varnishtest-exec,代码行数:27,代码来源:VarnishtestExecutor.java

示例2: exec

import org.apache.commons.exec.environment.EnvironmentUtils; //导入方法依赖的package包/类
public Process exec(final CommandLine cmd, final Map env)
        throws IOException {
    String[] envVar = EnvironmentUtils.toStrings(env);
    return Runtime.getRuntime().exec(cmd.toStrings(), envVar);
}
 
开发者ID:deim0s,项目名称:XWBEx,代码行数:6,代码来源:CommandLauncherImpl.java

示例3: exec

import org.apache.commons.exec.environment.EnvironmentUtils; //导入方法依赖的package包/类
/**
 * Launches the given command in a new process, in the given working
 * directory
 * 
 * @param cmd
 *            the command line to execute as an array of strings
 * @param env
 *            the environment to set as an array of strings
 * @param workingDir
 *            the working directory where the command should run
 * @throws IOException
 *             probably forwarded from Runtime#exec
 */
public Process exec(final CommandLine cmd, final Map env,
		final File workingDir) throws IOException {

	String[] envVars = EnvironmentUtils.toStrings(env);

	return Runtime.getRuntime().exec(cmd.toStrings(),
               envVars, workingDir);
}
 
开发者ID:deim0s,项目名称:XWBEx,代码行数:22,代码来源:Java13CommandLauncher.java


注:本文中的org.apache.commons.exec.environment.EnvironmentUtils.toStrings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。