tag : Java

Quick start: swagger, spring-boot and Jersey

在做服务器端API开发的时候,如何保持文档的更新是一个比较头疼的问题。试过写成word文档,缺点很明显: 更新不及时 不便于查阅 也试过用其他的在线API管理工具,太懒了,总是无法保持更新。而且大多数服务还是收费的。

Java: JDK居然有个叫整型池的东西

其实下面这些个assert语句都可以通过junit测试。 [email protected] void integerValueOfTest() { Assert.assertTrue(Integer.valueOf(-128) == Integer.valueOf(-128)); Assert.assertFalse(Integer.valueOf(128) == Integer.valueOf(128)); Assert.assertTrue(Integer.valueOf(127) == Integer.valueOf(127)); Assert.assertTrue(Integer.valueOf(1) == Integer.valueOf(1)); Assert.assertFalse(Integer.valueOf(1000) == Integer.valueOf(1000));}

Java Mail中文乱码

由于长时间在自己coding中处理英文内容,导致今天发现自己在做的一单网站在给用户发新密码邮件的时候居然中文乱码。(原来我每天都说的中文在我写代码的时候被忽略了)

Java: Test a file is image or not

There are many ways to check whether a file is image. For example, check the file extension(jpg, png, gif …). But this is not so safe, in a web environment, user may rename XXX.exe, to XXX.jpg, then s/he can succeed to upload it. In this case, it can induce security problem.

Design Pattern: Decorator & Proxy

I think it is better to master 23 Design Patterns as a Java developer. After I have a brief study, I find design pattern is not a new concept, and I have already used some of them in my daily projects unconsciously. Here I will describe some details about Decorator and Proxy, as I find they share something in common.