Á¦¸ñ : JAVA Module & Tip 1.(C¿¡¼ÀÇ system»ç¿ë)
import java.io.*;
import java.lang.*;
public class runtime {
public static void main(String args[])
{
if (args.length < 1) {
System.err.println("usage: javac runtime command\n");
System.exit(1);
}
StringBuffer command = new StringBuffer();
for( int i = 0; i < args.length; i++ )
command.append(args[i]+ " ");
Process ps = null;
OutputStream out = null;
BufferedReader in = null;
String res =null;
try {
ps = Runtime.getRuntime().exec(command.toString());
}catch(IOException e) {
System.out.println(e);
}
in = new BufferedReader(new InputStreamReader(
ps.getInputStream()));
out = ps.getOutputStream();
try {
while((res = in.readLine()) != null)
System.out.println(res);
}catch(IOException e) {
System.out.println(e);
}
}
}
-------------------------------------------------
°á°ú:
--------------------------------------------------
¼³¸í.
Java¿¡¼´Â RuntimeÀ» »ç¿ëÇÏ¿© CÀÇ systemÀÇ ±â´ÉÀ» Á¦°øÇÕ´Ï´Ù.
À§ÀÇ ¼Ò½º´Â javalandÀÇ ¼Ò½º¸¦ ÂüÁ¶Çß½À´Ï´Ù.
±Ã±ÝÇÑÁ¡ÀÖÀ¸¸é Q&A¿¡ ±ÛÀ»³²°ÜÁÖ¼¼¿ä
|