Java µ÷ÓÃEXE
ʹÓÃRuntime.getRuntime().exec()·½·¨¿ÉÒÔÔÚjava³ÌÐòÀïÔËÐÐÍⲿ³ÌÐò.
¸Ã·½·¨ÓÐ6¸ö¿É·ÃÎÊ°æ±¾:
1.exec(String command)
2.exec(String command, String envp[], File dir)
3.exec(String cmd, String envp[])
4.exec(String cmdarray[])
5.exec(String cmdarray[], String envp[])
6.exec(String cmdarray[], String envp[], File dir)
Ò»°ãµÄÓ¦ÓóÌÐò¿ÉÒÔÖ±½ÓʹÓõÚÒ»°æ±¾,µ±Óл·¾³±äÁ¿´«µÝµÄʱºòʹÓúóÃæµÄ°æ±¾.
ÆäÖÐ2ºÍ6°æ±¾¿ÉÒÔ´«µÝÒ»¸öĿ¼,±êʶµ±Ç°Ä¿Â¼,ÒòΪÓÐЩ³ÌÐòÊÇʹÓÃÏà¶ÔĿ¼µÄ,ËùÒÔ¾ÍҪʹÓÃÕâ¸ö°æ±¾.
µ±ÒªÖ´ÐÐÅú´¦ÀíµÄʱºò,²»ÄÜÖ±½Ó´«µÝÅú´¦ÀíµÄÎļþÃû,¶øҪʹÓÃ:
cmd.exe /C start Åú´¦ÀíÎļþÃû
ʹÓÃdosÃüÁî(±ÈÈçdir)ʱҲҪʹÓõôµ÷ÓÃ.
Èç¹ûÏëÓëµ÷ÓõijÌÐò½øÐн»»¥,ÄÇô¾ÍҪʹÓø÷½·¨µÄ·µ»Ø¶ÔÏóProcessÁË,ͨ¹ýProcessµÄgetInputStream(),getOutputStream(),getErrorStream()·½·¨¿ÉÒԵõ½ÊäÈëÊä³öÁ÷,È»ºóͨ¹ýInputStream¿ÉÒԵõ½³ÌÐò¶Ô¿ØÖÆ̨µÄÊä³öÐÅÏ¢,ͨ¹ýOutputStream¿ÉÒÔ¸ø³ÌÐòÊäÈëÖ¸Áî,ÕâÑù¾Í´ïµ½Á˳ÌÐòµÄ½»»»¹¦ÄÜ.
Àý×ÓÈçÏÂ:
package com.broadcontact.netadmin.schedule;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Date;
import java.io.StringReader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.File;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
/**
* <p>Title: netadmin</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company:
Ïà¹ØÎĵµ£º
¹ØÓÚjavaµÄhttpÐÒéÎļþÉÏ´«ÊµÓÃÀýÌâÒ»
(2006-07-25 16:43:56)
תÔØ
·ÖÀࣺ
java
¹ØÓÚjavaµÄhttpÐÒéÉÏ´«:(¼òµ¥ÊµÓöøÇÒ½¡×³;Ëٶȿì)
´Ë·½·¨±ÈapacheµÄÎļþÉÏ´«°ü(uploadfile1.1:¾ÍÎļþÉÏ´«¹¦ÄܶøÑÔ)Ҫǿ¶àÁË
1.Ö»ÐèÒªÒ»¸öMultipartRequest.java»ù±¾Îļþ¾ÍÐС£
2.ǰ̨htmlµÄ»ù±¾¸ñʽ
<html ......
»ñµÃmysqlºÍoracleÁ´½ÓµÄÀà
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectDB {
private static final String MYSQL = "jdbc:mysql://";
private static final String ORACLE = "jdbc:oracle:thin:@";
private ConnectD ......
package stone;
public class PrimerNumber {
public static void main(String[] args) {
int MAX_NUMBER = 100;
boolean[] notPrimer= new boolean[MAX_NUMBER];
for(int i=2;i<=MAX_NUMBER;i++){
if(!notPrimer[i-1]){
for(int j=2*i;j<=MAX_NUMBER;j++){
if(j%i==0) notPrimer[j-1]=tr ......
ƪÎÄÕÂÊÇ×î½ü¸Õ¿´µ½µÄ£¬ËäÈ»ÊÇ˵³ÌÐòÔ±´ÓC++תJAVAÐèҪעÒâµÄµØ·½£¬µ«ÊǺÜÏêϸµÄ˵³öÁËC++ºÍJAVAµÄ²»Í¬µÄµØ·½£¬¶ÔÓÚJAVAÖÐΪʲôûÓÐÖ¸Õ롢ΪʲôûÓÐÄÚ´æй¶¡¢½Ó¿ÚºÍC++ÖжàÖؼ̳еĹØϵ¡¢Òì³£»úÖƵÈÎÊÌâÒ²ÃèÊöµÄºÜÏêϸ£¬¹ÊתÔعýÀ´¡£
1.JavaÔÚÐéÄâ»úÉÏÔËÐÐ
JavaÔ´´úÂë²¢²»ÊDZ»±àÒë³ÉΪÆÕͨµÄ»úÆ÷´úÂë¡£¶øÊDZ»·Òë³ÉÎ ......
JavaÓïÑÔµÄ26¸öϸ½Ú[תÔØ]
Java×÷ΪһÃÅÓÅÐãµÄÃæÏò¶ÔÏóµÄ³ÌÐòÉè¼ÆÓïÑÔ,ÕýÔÚ±»Ô½À´Ô½¶àµÄÈËʹÓᣱ¾ÎÄÊÔͼÁгö×÷ÕßÔÚʵ¼Ê¿ª·¢ÖÐÅöµ½µÄһЩJavaÓïÑÔµÄÈÝÒ×±»È˺öÊÓµÄϸ½Ú,Ï£ÍûÄܸøÕýÔÚѧϰJavaÓïÑÔµÄÈËÓÐËù°ïÖú¡£
1£¬Î»ÒÆÔËËãÔ½½çÔõô´¦Àí
¿¼²ìÏÂÃæµÄ´úÂëÊä³ö½á¹ûÊǶàÉÙ?
int a=5;
......