Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Javaµ÷ÓÃLinuxÃüÁî

Java¿ÉÒÔÖ±½Óµ÷ÓÃLinuxÃüÁÐÎʽÈçÏ£º
 Runtime.getRuntime().exec(command)
 ¾ÙÀý£ºÔËÐÐls,topÃüÁî¿ÉÒÔÕâÑù£º
 Runtime.getRuntime().exec("ls");
 µ«ÊÇÕâÑùÖ´ÐÐʱûÓÐÈκÎÊä³ö£¬Ô­Òò£º 
 µ÷ÓÃRuntime.exec·½·¨½«²úÉúÒ»¸ö±¾µØµÄ½ø³Ì,²¢·µ»ØÒ»¸öProcess×ÓÀàµÄʵÀý£¬
£¨×¢Ò⣺Runtime.getRuntime().exec£¨command£©·µ»ØµÄÊÇÒ»¸öProcessÀàµÄʵÀý£©,
¸ÃʵÀý¿ÉÓÃÓÚ¿ØÖƽø³Ì»òÈ¡µÃ½ø³ÌµÄÏà¹ØÐÅÏ¢. ÓÉÓÚµ÷ÓÃRuntime.exec·½·¨Ëù´´½¨µÄ×Ó½ø³ÌûÓÐ×Ô¼ºµÄÖն˻ò¿ØÖÆ̨,Òò´Ë¸Ã×Ó½ø³ÌµÄ±ê×¼IO(Èçstdin,stdou,stderr)¶¼Í¨¹ýProcess.getOutputStream(),Process.getInputStream(), Process.getErrorStream()·½·¨Öض¨Ïò¸øËüµÄ¸¸½ø³ÌÁË.Óû§ÐèÒªÓÃÕâЩstreamÀ´Ïò×Ó½ø³ÌÊäÈëÊý¾Ý»ò»ñÈ¡×Ó½ø³ÌµÄÊä³ö. ¿ÉÒÔ²ÉÓÃÈçÏ·½·¨£º
public static void main(String[] agrs){
try
{
 Process process = Runtime.getRuntime().exec ("ls"); 
 InputStreamReader ir=newInputStreamReader(process.getInputStream());
 LineNumberReader input = new LineNumberReader (ir);
 String line;
 while ((line = input.readLine ()) != null){
  System.out.println(line)
}
}catch (java.io.IOException e){
 System.err.println ("IOException " + e.getMessage());
}
}


Ïà¹ØÎĵµ£º

java³õѧ֮»ù´¡ÎÊÌâ½â´ð——ÄÚ²¿Àà


 public class OuterClass
 {
 public class InnerClass
 {
 public int code = 100;
 }
 public static void main(String[] args)
 {
 OuterClass outer = new OuterClass();
 OuterClass.InnerClass o = outer.new InnerClass();
 System. ......

½ÌÄãÉîÈëÁ˽âJavaÖнӿڵÄʹÓÃ

±¾ÆªÎÄÕÂÀ´Ô´ÓÚ£º¿ª·¢Ñ§Ôº http://edu.codepub.com   Ô­ÎÄÁ´½Ó£ºhttp://edu.codepub.com/2010/0221/20469.php
      ½Ó¿ÚÉêÃ÷±ØÐëÓÐinterface¹Ø¼ü×ֺͽӿڵÄÃû×Ö£¬publicÖ¸Ã÷ÈÎÒâÀà¾ù¿ÉÒÔʹÓÃÕâ¸ö½Ó¿Ú£¬Ä¬ÈÏÇé¿öÏ£¬Ö»ÓÐÓë¸Ã½Ó¿Ú¶¨ÒåÔÚͬһ¸ö°üÖеÄÀà²Å¿ÉÒÔ·ÃÎÊÕâ¸ö½Ó¿Ú¡£extends ÓëÀà ......

ÅäÖÃJAVA¿ª·¢»·¾³

Ê×ÏȽéÉÜһϻ·¾³±äÁ¿µÄÉèÖ÷½·¨£º
£¨ÕâÀïÒÔjdk1.5À´°²×°£¬ÆäËû°æ±¾Ò»Ñù£©
ÔÚ°Ñjdk1.5°²×°µ½¼ÆËã»úÖÐÖ®ºó£¬ÎÒÃÇÀ´½øÐÐÉèÖÃʹjava»·¾³Äܹ»Ê¹Óá£
         Ê×ÏÈÓÒ¼üµãÎҵĵçÄÔ¡£´ò¿ªÊôÐÔ¡£È»ºóÑ¡Ôñ“¸ß¼¶”ÀïÃæµÄ“»·¾³±äÁ¿”£¬ÔÚеĴò¿ª½çÃæÖеÄϵͳ±äÁ¿Ð ......

Linux x86 run time process manipulation

[------------------------------------------------------------------------]
[-- Uninformed Research -- informative information for the uninformed. --]
[------------------------------------------------------------------------]
[-- Genre : Development ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ