kkcheng
kkcheng · 共 26 篇文章
android autoanswer
http://code.google.com/p/auto-answer/ Here is a code snippet to trigger an answer for the incoming call: private void answerPhoneAidl(Context context) throws Exception { // Set up communication with the telephony service (thanks to Tedd's Droid Tools!) TelephonyManager tm = (TelephonyManager) getSy…
2014-08-29 14:51 · 评论(0)
Java资源加载详解
Java资源加载详解 Java开发中常常要加载各种各样的资源文件,如property文件,xml配置文件,图片文件等等。 Java的资源加载策略选择比较多,很多资源加载方法都是基于不同的项目配置,没有一种资 源加载方法是万能的。首先来看看Java中的几种常见的资源加载方法: 一:通过ResourceBundle类来实现资源加载 这种方式通常被用来加载多语言支持的property文件,Java语言通过ResourceBundle可以非 常好的支持国际化。假设在默认为英文的系统中有语言资源文件mybundle_en.properties,则 调用代码如下: ResourceBundle myBu…
2014-02-05 11:18 · 评论(0)
linux下生成key
使用public/private key让putty(ssh)自动登录(以及linux上使用密钥做ssh自动登陆) 方法一:使用puttygen.exe 第一步:生成密匙 运行puttygen.exe,选择需要的密匙类型和长度,使用默认的SSH2(RSA),长度设置为1024就可以了。 passphrase可以为空,免得登录时还是要输入一次密码。 点击Save private key 按钮保存公匙和私匙,例如key.ppk,public key不用保存,以后使用Puttygen.exe Load功能就可以显示public key。 第二步:上传密匙 用自己的帐号登录linux主机,然后执行下…
2013-08-20 16:38 · 评论(0)
linux下java环境配置
文本启动: #vi /etc/inittab 把default设为3: linux给用户添加sudo权限: 有时候,linux下面运行sudo命令,会提示类似: xxxis not in the sudoers file. This incident will be reported. 这里,xxx是用户名称,然后导致无法执行sudo命令,这时候,如下解决: 1.进入超级用户模式。也就是输入"su -",系统会让你输入超级用户密码,输入密码后就进入了超级用户模式。(当然,你也可以直接用root用) 2.添加文件的写权限。也就是输入命令"chmod u+w /etc/sudoers"。 3.编…
2013-07-10 22:25 · Linux · 评论(0)
mvc annotation
在Spring3.0中 在Spring3.0.5这个版本上, mvc:annotation-driven/ 声明是没有 defaultAnnotationHandlerMapping这个属性的,对于@ResultMapping标签的解析,是写死了必须用 "org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping” 这个类来处理的。 在Spring 2.5中 那么Spring是如何解析 mvc:annotation-driven/ 标签的呢? 首先,必须要有一个继承自“org.springfra…
2012-05-22 13:33 · 评论(0)
java读取文件
读取文件方法大全 1、按字节读取文件内容 2、按字符读取文件内容 3、按行读取文件内容 4、随机读取文件内容 复制代码 public class ReadFromFile { /** * 以字节为单位读取文件,常用于读二进制文件,如图片、声音、影像等文件。 */ public static void readFileByBytes(String fileName) { File file = new File(fileName); InputStream in = null; try { System.out.println("以字节为单位读取文件内容,一次读一个字节:"); // 一次读一…
2012-05-03 17:41 · 评论(0)
bdd
http://www.hascode.com/2011/05/oh-jbehave-baby-behaviour-driven-development-using-jbehave/#Setting_up_a_test_project
2012-04-25 13:18 · 评论(0)
jersery test
<dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>0.9.28</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> <version>0.9.28</version> </dependency> <dependency> <groupId>com.googlecode.ehcache-s…
2012-04-17 15:51 · 评论(0)
Restful TDD maven配置
<dependency> <groupId>com.sun.jersey.contribs</groupId> <artifactId>jersey-spring</artifactId> <version>1.6</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-co…
2012-04-16 13:38 · 评论(0)
spring3.1 加载不进PropertyPlaceholderConfigurer
最近项目升级,spring3.1+mybatis3.1+mybatis-spring1.1.0 数据查询时老是报classNotFound ${jdbc.driverClassName},debuy源码发现PropertyPlaceholderConfigurer在BasicDataSource之后载,正常的情况下应该是这前加载?网上搜了下得到如下结构: 我用spring3.0.6+mybatis3.0.6+mybatis-spring1.0.2做了一个demo,我把数据库连接驱动放在src下,但是我在spring配置文件中加上 <context:property-placeholder l…
2012-04-09 13:31 · 评论(2)
spring restful
随附文章,“使用 Spring 3 构建 RESTful web 服务”(参见 参考资料),介绍了使用 Spring 构建 RESTful web 服务的方式。还解释了如何使用 ContentNegotiatingViewResolver 生成多个具象,这是 RESTful web 服务的一个重要功能。本文还阐述了使用 HttpMessageConverter 生成多个具象的另一种方式,并且本文中的示例展示了如何使用 RestTemplate 和 HttpMessageConverter 与服务进行通信。 回页首 Spring MVC 中的 REST 支持 本部分提供了支持 RESTful …
2012-03-22 23:25 · 评论(0)
@ResponseBody & @RequestBody
@ResponseBody & @RequestBody 作用? @RequestBody 将 HTTP 请求正文插入方法中,使用适合的HttpMessageConverter将请求体写入某个对象。 @ResponseBody 将内容或对象作为 HTTP 响应正文返回,使用@ResponseBody将会跳过视图处理部分,而是调用适合HttpMessageConverter,将返回值写入输出流。 HttpMessageConverter接口 <mvc:annotation-driven />开启了之后它给AnnotationMethodHandlerAdapter初始化7个转换器,可以通过调用…
2012-03-22 22:59 · 评论(0)
spring sample url
http://www.mkyong.com/spring-mvc/spring-3-mvc-and-json-example/ http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-annotation-driven spring mvct beging http://www.cnblogs.com/zhaoyang/archive/2012/01/07/2315403.html http://static.springsource.org/spring/do…
2012-03-22 22:44 · 评论(0)
转:Spring3 MVC
大家好,Spring3 MVC是非常优秀的MVC框架,由其是在3.0版本发布后,现在有越来越多的团队选择了Spring3 MVC了。Spring3 MVC结构简单,应了那句话简单就是美,而且他强大不失灵活,性能也很优秀。 官方的下载网址是:http://www.springsource.org/download (本文使用是的Spring 3.0.5版本) Struts2也是比较优秀的MVC构架,优点非常多比如良好的结构。但这里想说的是缺点,Struts2由于采用了值栈、OGNL表达式、struts2标签库等,会导致应用的性能下降。Struts2的多层拦截器、多实例action性能都很好。可…
2012-03-22 22:25 · 评论(0)
sping DefaultAnnotationHandlerMapping
If you define custom HandlerMapping beans in your DispatcherServlet context, you need to add a DefaultAnnotationHandlerMapping bean explicitly, since custom HandlerMapping beans replace the default mapping strategies. Defining a DefaultAnnotationHandlerMapping also allows for registering custom int…
2012-03-22 22:15 · 评论(0)