zoukankan      html  css  js  c++  java
  • java代码调用bat文件

    package com.gyb;
    import java.io.IOException;
    import java.io.InputStream;

    public class InvokeBat4 {
        public void runbat(String batName) {
            String cmd = "cmd /k start D:\new\news.bat";// pass
            try {
                Process ps = Runtime.getRuntime().exec(cmd);
                InputStream in = ps.getInputStream();
                int c;
                while ((c = in.read()) != -1) {
                    System.out.print(c);// 如果你不需要看输出,这行可以注销掉
                }
                in.close();
                ps.waitFor();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
            catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println("child thread donn");
        }

        public static void main(String[] args) {
            InvokeBat4 test1 = new InvokeBat4();
            test1.runbat("news");
            System.out.println("main thread");
        }
    }

    ------bat文件中这样写

    d:& cd new
    java -jar -Xmn600m -Xms1200m -Xmx1200m lmsp-news-snatch.jar
    exit

  • 相关阅读:
    jsp九大内置对象和4个域对象
    小甜点
    response编码
    request请求编码处理
    防盗链模拟
    request浏览器判断
    request获取ip
    ServletConfig
    HttpServlet原理
    Servlet,GenericServlet,httpServlet区别
  • 原文地址:https://www.cnblogs.com/gyb109/p/6601757.html
Copyright © 2011-2022 走看看