Java Linux 时区同步设置和重启 arm端

来源:互联网 发布:淘宝网的卖家中心在哪 编辑:程序博客网 时间:2024/06/05 08:42
import java.io.IOException;

public class SetUpToLed {
//时区同步设置
    public static void setTimeZone(String timeZoneStr) {
        //timeZoneStr = "Pacific/Guam";
        String timezone = "sudo cp -f /usr/share/zoneinfo/" + timeZoneStr
                + " /etc/localtime";
        System.out.println(timezone);
        try {

            String[] cmds = { "/bin/sh", "-c", timezone };
            Process pro = Runtime.getRuntime().exec(cmds);
            pro.waitFor();
            Thread.sleep(2000);
            Process pro1 = Runtime.getRuntime().exec("sudo reboot");
            pro1.waitFor();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    //重启系统
    public void reBootSystem() throws IOException, InterruptedException{
        Process pro1 = Runtime.getRuntime().exec("sudo reboot");
        pro1.waitFor();
    }
}

原创粉丝点击