易截截图软件、单文件、免安装、纯绿色、仅160KB

java 调用系统可执行程序

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class RunDosCommand {
  public static void main(String[] args) throws IOException {
      String cmd = "ipconfig";
      Runtime run = Runtime.getRuntime();
      Process p = run.exec(cmd);
      BufferedInputStream in = new BufferedInputStream(p.getInputStream());
      BufferedReader br = new BufferedReader(new InputStreamReader(in));
      String s;
      while ((s = br.readLine()) != null)
          System.out.println(s);
  }
}
输出结果:
Windows IP Configuration
Ethernet adapter 區域連線:
Connection-specific DNS Suffix . : iacp.iac
IP Address. . . . . . . . . . . . : 10.162.54.45
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.162.54.1
Ethernet adapter 無線網路連線:
Media State . . . . . . . . . . . : Media disconnected
Ethernet adapter VirtualBox Host-Only Network:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.56.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
输出的结果因电脑的不同,而不相同。
注:这样的情况下,是不会有Dos窗口弹出的。
public class RunDosCommand {
/**
* @param args
* @throws IOException 
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
String path = System.getProperty("user.dir")+"/command/d.bat";
Runtime run = Runtime.getRuntime();
Process process = run.exec("cmd.exe /c start "+path);
   }
}
执行d.bat中的命令。



相关文档:

java实现zip与unzip

jdk提供了Zip相关的类方便的实现压缩和解压缩。使用方法很简单。下边分别是压缩和解压缩的简单事例
1,压缩的
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import ......

java 连接字符串

1. MySQL(http://www.mysql.com)mm.mysql-2.0.2-bin.jar ;
Class.forName( "org.gjt.mm.mysql.Driver" );
cn = DriverManager.getConnection( "jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName", sUsr, sPwd );
2. PostgreSQL(http://www.de.postgresql.org)pgjdbc2.jar ;
Class.forName( "org.postgresql. ......

Java读取PDF,Doc的方法

很多人问到如何抽取word,excel,pdf阿。这里我总结一下抽取word,pdf的
几种方法。
1。用jacob.
其实jacob是一个bridage,连接java和com或者win32函数的一个中间件,jacob并不能直接抽取word,excel等文件,需要自己写dll哦,不过已经有为你写好的了,就是jacob的作者一并提供了。
jacob下载:http://www.matrix.org ......

谈谈Java继承中的重载,覆盖和隐藏

谈谈Java继承中的重载,覆盖和隐藏
好久不写博客了,距离上一篇已经过了两年多了。这两年在干嘛,总之一年难尽!
前一段时间忙了两个月,忙着研究和做一些SSH架构的东西,两个月下来,收获颇丰,最近闲下来了,于是就痛快的开始玩游戏,但是不知怎么地,怎么玩都没意思,于是决定开始再好好研究研究Java吧。于是大概翻了翻 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号