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

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);
                }
        }
}

arrow
arrow
    全站熱搜

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