jahiacmdexec.java

来自「java 写的一个新闻发布系统」· Java 代码 · 共 94 行

JAVA
94
字号
////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////                 . . . i n   j a h i a   w e   t r u s t . . .////////  JahiaCmdExec////  NK      13.01.2001////package org.jahia.utils;import java.io.*;import org.jahia.exceptions.*;import org.jahia.utils.*;/** * Execute an External Command Line * * @author Khue ng */public class JahiaCmdExec {   protected String m_Cmd = "";   /**    * Constructor    *    * @param (String) cmd, the command line    */   public JahiaCmdExec(String cmd) {      m_Cmd = cmd;   }   /**    * Execute the command in the current working dir    *    * @exception (JahiaException) on error    */   public void execute() throws JahiaException {      try {         Process process = Runtime.getRuntime().exec(m_Cmd);      } catch (Exception e) {         String errMsg = "Failed executing command line " + m_Cmd ;         JahiaConsole.println("JahiaCmdExec::execute()", errMsg + "\n" + e.toString());         throw new JahiaException ("JahiaCmdExec", errMsg ,                                    JahiaException.SERVICE_ERROR, JahiaException.WARNING, e);      }   }   /**    * Execute the command in a specified working dir    *    * @param (File) workingDir , The abstract File object to the new working dir    * @exception (JahiaException) on error    */   public void execute(File workingDir) throws JahiaException {      try {         Process process = Runtime.getRuntime().exec(m_Cmd,new String[]{""},workingDir);      } catch (Exception e) {         String errMsg = "Failed executing command line " + m_Cmd ;         JahiaConsole.println("JahiaCmdExec::execute()", errMsg + "\n" + e.toString());         throw new JahiaException ("JahiaCmdExec", errMsg ,                                    JahiaException.SERVICE_ERROR, JahiaException.WARNING, e);      }   }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?