JAVA调用linux中的shell命令行的工具类

二话不说,直接上代码!


package cn.sigangjun.util;

/**
 * 

Title:java call linux shell util

*

Description: java call linux shell util

* @since 2013-8-12 下午3:50:15 * @version 1.0 * @author sigangjun */ public class JavaShellUtil { public static int executeShell(String shellCommand) { int success = 0; try { String[] cmd = {"/bin/sh", "-c", shellCommand}; Process pid = Runtime.getRuntime().exec(cmd); if (pid == null) { success = 1; } } catch (Exception e) { e.printStackTrace(); success = 1; } return success; } }



你可能感兴趣的:(java编程技巧,java,utils,linux)