java如何开启一个dos窗口?
来源:互联网 发布:社交软件的盈利模式 编辑:程序博客网 时间:2024/05/14 15:44
- try {
- Process process = Runtime.getRuntime().exec("cmd.exe");
- OutputStream outputStream = process.getOutputStream();
- final InputStream inputStream = process.getInputStream();
- new Thread(new Runnable(){
- byte[] cache = new byte[1024];
- public void run() {
- System.out.println("listener started");
- try {
- while(inputStream.read(cache)!=-1){
- System.out.println(new String(cache));
- }
- } catch (IOException e) {
- //e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
- }).start();
- outputStream.write(new byte[]{'d','i','r','/n'});
- //inputStream.
- int i = process.waitFor();
- System.out.println("i=" + i);
- } catch (Exception e) {
- e.printStackTrace();
- }
try { Process process = Runtime.getRuntime().exec("cmd.exe"); OutputStream outputStream = process.getOutputStream(); final InputStream inputStream = process.getInputStream(); new Thread(new Runnable(){ byte[] cache = new byte[1024]; public void run() { System.out.println("listener started"); try { while(inputStream.read(cache)!=-1){ System.out.println(new String(cache)); } } catch (IOException e) { //e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } }).start(); outputStream.write(new byte[]{'d','i','r','/n'}); //inputStream. int i = process.waitFor(); System.out.println("i=" + i); } catch (Exception e) { e.printStackTrace(); }
明白了没?
ggmmaallee (初级程序员) 2008-06-02
- try {
- Process process = Runtime.getRuntime().exec("cmd.exe");
- final BufferedWriter outputStream = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
- final BufferedReader inputStream = new BufferedReader(new InputStreamReader(process.getInputStream()));
- new Thread(new Runnable() {
- String line;
- public void run() {
- System.out.println("listener started");
- try {
- while ((line=inputStream.readLine()) != null) {
- System.out.println(line);
- }
- } catch (IOException e) {
- //e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
- }).start();
- new Thread(new Runnable() {
- final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- public void run() {
- System.out.println("writer started");
- String line;
- try {
- while ((line = br.readLine()) != null) {
- outputStream.write(line + "/r/n");
- outputStream.flush();
- }
- } catch (IOException e) {
- //e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
- }).start();
- int i = process.waitFor();
- System.out.println("i=" + i);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- java如何开启一个dos窗口?
- java 代码打开一个dos窗口
- Qt如何添加DOS窗口
- dos窗口运行java程序
- java如何创建一个窗口出来
- 如何开启一个事务
- 如何开启一个项目
- win32程序中创建一个DOS窗口
- 如何获得Dos窗口命令输出结果
- 如何关闭打开的dos窗口?
- 如何拷贝CMD DOS 窗口中的内容
- 如何拷贝CMD DOS 窗口中的内容
- mfc如何显示dos窗口,调试程序
- 如何复制dos窗口里的内容
- DOS窗口如何实现复制粘贴
- Dos窗口一闪而过,如何查看错误?
- 如何调整DOS窗口的宽高
- C语言 如何隐藏DOS窗口
- 在java中調用dos命令,摹擬DOS窗口
- linux--12点
- GL Studio
- 罚款对杜绝迟到有效吗?
- .NET 语言的 using statement 与资源释放
- java如何开启一个dos窗口?
- MySQL数据的导出和导入工具:mysqldump(备份数据库的命令)
- 委托的概念
- 美国著名杂志及其网址
- native2ascii----jdk自带编码转换工具
- 美国经济危机和中国经济危机的区别
- 在DataList中使用RadioButton,注意下面脚本的写法(在用户控件中)
- w3c概述
- linux轻松实现英文版操作系统