此功能是因為大學時用到,所以就筆記下來!

import java.io.*;

public class cmd
{
        public static void main(String args[]) throws IOException
        {
                try
                {
                      String[] cmd={" /bin/bash","-c","ls -l > ls.log"};
                      Runtime.getRuntime().exec(cmd);
                }
                catch (IOException e)
                {
                       System.err.println(e);
                }
        }
}

dreamtails 發表在 痞客邦 PIXNET 留言(0) 人氣()