• 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

  • 相关阅读:
    探究Spark算子-RDD
    Spark架构中YarnCluster模式作业流程
    Spark运行架构和组件
    Spark部署模式&端口号&提交作业参数说明
    Spark和Hadoop的联系和区别
    Idea中文件大小配置
    设计模式-之Scala单例模式
    HDFS集群格式化踩过的坑
    安装Spark时遇见的坑
    配置群起zookeeper的脚本所踩过的坑
  • 原文地址:https://www.cnblogs.com/gyb109/p/6601757.html
Copyright © 2020-2023  润新知