java调用其它程序之返回值
来源:互联网 发布:公益网络平台 编辑:程序博客网 时间:2024/04/28 17:04
Process process = Runtime.getRuntime().exec("cmd /c dir");
System.out.println(loadStream(process.getInputStream())); //load the stream
System.out.println(loadStream(process.getErrorStream())); //load the stream
static String loadStream(InputStream in) throws IOException
{
int ptr = 0;
in = new BufferedInputStream(in);
StringBuffer buffer = new StringBuffer();
while ( (ptr = in.read()) != -1)
{
buffer.append( (char) ptr);
}
return buffer.toString();
}
---------------------------
刚才那个loadStream方法,如果dir里面有汉字则显示为乱码。应将该方法修改为如下:
static String loadStream(InputStream in) throws IOException
{
int ptr = 0;
in = new BufferedInputStream(in);
StringBuffer buffer = new StringBuffer();
while ( (ptr = in.read()) != -1)
{
buffer.append( (char) ptr);
}
String aa=buffer.toString();
byte[] temp= aa.getBytes("ISO-8859-1");
String result=new String(temp);
return result;
}
System.out.println(loadStream(process.getInputStream())); //load the stream
System.out.println(loadStream(process.getErrorStream())); //load the stream
static String loadStream(InputStream in) throws IOException
{
int ptr = 0;
in = new BufferedInputStream(in);
StringBuffer buffer = new StringBuffer();
while ( (ptr = in.read()) != -1)
{
buffer.append( (char) ptr);
}
return buffer.toString();
}
---------------------------
刚才那个loadStream方法,如果dir里面有汉字则显示为乱码。应将该方法修改为如下:
static String loadStream(InputStream in) throws IOException
{
int ptr = 0;
in = new BufferedInputStream(in);
StringBuffer buffer = new StringBuffer();
while ( (ptr = in.read()) != -1)
{
buffer.append( (char) ptr);
}
String aa=buffer.toString();
byte[] temp= aa.getBytes("ISO-8859-1");
String result=new String(temp);
return result;
}
- java调用其它程序之返回值
- java调用其它程序之记事本
- java 调用其它程序
- 从java程序中调用其它程序
- 从java程序中调用其它程序
- C#调用其它程序
- .NET 程序,调用其它程序
- 也谈在Java中调用其它的程序
- java程序调用存储过程一(返回特定值)
- excel中vba调用java程序并获取返回值
- Java程序调用带参数的shell脚本返回值
- Java程序调用带参数的shell脚本返回值
- java程序调用Oracle 存储过程 获取返回值(无返回,非结果集,结果集)
- 出学者入门:从java程序中调用其它程序 — IT技术 - 赛迪网
- ActionResult的其它返回值
- ActionResult的其它返回值
- ActionResult的其它返回值
- 程序调用 - 命令参数 和 返回值
- Composite UI Application Block学习笔记之一
- 500-IIS服务器内部错误解决方法
- 使用MQ传输结构体信息
- VOIP传输中的音频codec
- 嵌入式Linux开发资源大全
- java调用其它程序之返回值
- 测试服务器到服务器的MQ传输
- VMare里linux使用MINCOM通信~~强~
- 程序员的话
- 在centos5下安装配置VNC
- MQ初探
- Mq安装配置
- linux下的tuxedo开发实例
- MQ的基本概念