当前位置: 技术问答>java相关
请问如何用java调用DOS命令行?
来源: 互联网 发布时间:2015-05-16
本文导语: DOS命令行如:msxsl test.xml test.xsl -o test.html 怎样才能调用? 还有就是有没有办法调用bat文件? | 一个 shell import java.util.*; import java.io.*; class StreamGobbler extends Thread { InputStream is; ...
DOS命令行如:msxsl test.xml test.xsl -o test.html
怎样才能调用?
还有就是有没有办法调用bat文件?
怎样才能调用?
还有就是有没有办法调用bat文件?
|
一个 shell
import java.util.*;
import java.io.*;
class StreamGobbler extends Thread
{
InputStream is;
String type;
Process p;
StreamGobbler(InputStream is, String type)
{
this.is = is;
this.type = type;
}
StreamGobbler(Process proc, String type)
{
p = proc;
this.type = type;
is = proc.getInputStream();
}
public void run()
{
try
{
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null)
System.out.println(type + ">" + line);
} catch (IOException ioe)
{
ioe.printStackTrace();
}
}
}
public class GoodWindowsExec
{
public static void main(String args[])
{
if (args.length
import java.util.*;
import java.io.*;
class StreamGobbler extends Thread
{
InputStream is;
String type;
Process p;
StreamGobbler(InputStream is, String type)
{
this.is = is;
this.type = type;
}
StreamGobbler(Process proc, String type)
{
p = proc;
this.type = type;
is = proc.getInputStream();
}
public void run()
{
try
{
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null)
System.out.println(type + ">" + line);
} catch (IOException ioe)
{
ioe.printStackTrace();
}
}
}
public class GoodWindowsExec
{
public static void main(String args[])
{
if (args.length