Mac 如果一定要写个锁屏程序的话就这样
2015-03-23 10:59
169 查看
package test; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class RuntimeCMD { private static Process p; public static void main(String[] args) throws IOException, InterruptedException { InputStream in=getInputStreambyExecScript("scripts/test.sh"); BufferedReader fr=new BufferedReader(new InputStreamReader(in)); String line; while((line=fr.readLine())!=null){ System.out.println(line); } p.waitFor(); fr.close(); p.destroy(); } private static InputStream getInputStream(String exec) throws IOException{ p=Runtime.getRuntime().exec(exec); return p.getInputStream(); } private static InputStream getInputStreambyExecScript(String exec) throws IOException{ p=Runtime.getRuntime().exec(new String[]{"/bin/sh","-c",exec},null,null); return p.getInputStream(); } }
script
#!/bin/bash '/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession' -suspend
相关文章推荐
- [Mac入门] 如果更快的打开程序或文件
- 验证视图MAC失败。如果此引用程序由网络场或群集承载... 解决方法
- 推荐逛家乐福最新程序(如果一定要进家乐福,请使用本程序)
- 验证视图MAC失败。如果此引用程序由网络场或群集承载,请确保<machineKey>配置指定了相同的 validationKey 和验证算法。不能在群集中使用 AutoGenerateP>
- 如果在ASP.NET程序中用到OracleConnection 接ORACLE(Oracle9i)数据库时的异常
- 如果我喜欢程序
- 如果你想学好C#!就一定要看这个!对你很多帮助!
- 如果你是女人一定要看
- 有感于:“如果程序的缩进超过 3 级,则应考虑重新设计程序”
- 什么时候应该使用Web Service? (我想问,如果在局域网里使用web service+windows程序来开发原来的C/S结构的程序,性能上差多少?)
- 如果客户端禁用cookie,那asp.net的form验证程序还能正常运行吗
- WINDOWS2003服务器如果需要perl或者java在服务器上能够执行可执行程序,需要做哪些配置?
- 使用libnet构造源mac持续更新的arp攻击程序
- 写完程序一定要查询游标
- asp程序 读取某IP的网卡MAC地址
- CSS解析器,如果需要在程序中处理CSS,则可以用到。
- 调用第三方程序Ping同局域网计算机和得到其Mac
- 如果要设计一个GPS定位程序
- 如何用VC++开发读取网卡MAC地址的程序
- 一定要在3 20前完成所有的程序开发工作