当前位置:编程学习 > JSP >>

给大家一个在SERVER端执行可执行程序的JAVABEAN,呵呵~~~

答案:/*
*Author:tyfun
*DateTime:2002.12.19
*Package:com.westarsoft.function
*/

package com.westarsoft.io;

import java.lang.*;
import java.io.*;

public class Execute {
    private static String cmdUrl = new String();
    private static String fileParam = new String();
    public String getCmdUrl() {
        return cmdUrl;
    }
    public void setCmdUrl(String cmdUrl) {
        this.cmdUrl = cmdUrl;
    }
    public String getFileParam() {
        return fileParam;
    }
    public void setFileParam(String fileParam) {
        this.fileParam = fileParam;
    }
    /*
     *USE:
     *setCmdUrl(String)
     *setFileParam(String)
     */    
    public void exec(String cmdUrl,String fileParam) {
        try {
            String[] cmd = {cmdUrl, fileParam};
            Runtime.getRuntime().exec(cmd);
        }
        catch(Exception e) {
            System.out.println(e);
        }
    }
}

上一个:正确地封装Java类
下一个:再给大家一个进行IO操作的JAVABEAN,易做图奉献哦~~~~搜集和调试了很久,没有问题哦~~~~

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,