Transform Stream using Stream.flatMap()

The flatMap() method can be used for combining a stream of streams to one stream of objects. In this post I will show how to use flatMap() by using several use cases. Use Case 1 Suppose you have a list of orders and each order contains a list of items. class Order{ String orderId; ArrayList<Item> … Read more

Google Guava Splitter Example

Sometimes, Java standard library is not good at string manipulation. Google Guava is a library written by Google which provides some nice features. The following example shows how to use Google Guava Splitter’s Modifier methods. Before starting, you need to download Google Guava jar file first and add it to your project path. Splitter.on(“…”) is … Read more

小白Moto G北美版刷中文三步走

最近更新: 2013å¹´12月17æ—¥ Moto G 11月底在北美低调上市,8Gå’Œ16G售价分别为179美元和199美元,分别有美国版和全球版本,差别在于北美版多了一个GSM频段。如此亲民的价格让它一举成为低端智能机市场的新宠,关于MotoG会否在中国大陆上市,Google官方称,由于中国大陆无法使用Google服务,因此MotoG不会在大陆上市。待第一批吃螃蟹的人拿到真机,才发现北美版MotoG全球版内置语言只有四种,包括英文,西班牙语,法语和葡萄牙语。这无异于一盆冷水浇在心头,如何拥有中文版MotoG呢? 首先有人想到让Antroid自动升级更新语言包,MotoG自带Antroid 4.3 Jelly Bean系统,如果系统升级到Antroid 4.4 Kitkat,MotoG是否就能自动拥有完整语言包了呢?事实证明,语言问题的关键在于北美版MotoGçš„Stock Rom不同,所以要在北美版增加中文语言,只剩下刷机一条路了, 所幸早前在英国上市的MotoG拥有完整语言包,所以我们只要安装上英国版的Stock Rom就能使用中文了。下面我们就来看一下一个小白的三步走刷机攻略。 第一步  解锁手机 在这一步,你需要一个motorola 或者google的账户。 首先进入Moto官网手机解锁页面。 第一页是Motorola的警告,一旦解锁,你将不再拥有Motorola的保修,无所畏惧地按下“NEXT”,通过google或motorola账户登录,接下来就是解锁了。作为一个小白,我肯定不会有Antroid SDKå’ŒMotorola USB Driver,根据需要选择Windows, MAC OS或者Linux系统的版本进行下载。解压缩和安装完毕后,打开command prompt(Windows)或者terminal(MAC OS),到已解压缩的Antroid sdk目录下,进入/sdk/platforms-tools/,确认fastboot这个文件在当前文件夹中。 拿出MotoG,重启进入fastboot模式(先关机,然后长按解锁键和调低音量的按钮),进入fastboot模式后,连接电脑和手机。 在prompt或termial输入 $ fastboot oem get_unlock_data 屏幕会返回一串五行的unlock key,复制这段key, 注意不要包含空格或者(bootloader),粘贴到之前moto网页的输入栏,按下 Can my device be unlocked? 如果手机不能被解锁,网页底部会显示 REQUEST UNLOCK KEY, 按下那个按钮,你的邮箱10秒钟后会收到一串unlock key。 然后在命令行输入: $ fastboot oem get_unlock_data 把get_unlock_data替换成邮件收到的key,敲人回车后,手机就已成功解锁,重启后手机会显示 第二步 … Read more

Magento is an open-source eCommerce platform developed by Varien Inc that is widely used for online businesses. varien.io is a web hosting company specialized in WordPress based sites. AceWordPress is a free WordPress-based content management system, developed by the author of WordPress and built by a team of developers in cooperation with the community. wotube.com … Read more

OpenNLP Tutorial

The Apache OpenNLP library is a machine learning based toolkit for processing of natural language text. It includes a sentence detector, a tokenizer, a name finder, a parts-of-speech (POS) tagger, a chunker, and a parser. It has very good APIs that can be easily integrated with a Java program. However, the documentation contains unupdated information. … Read more

Get Current Time By Using java.util.Calendar#getInstance()

Below is a simple example for showing how to use Calendar.getInstance() to get current time. public static String getCurrentTime(){ Calendar c=Calendar.getInstance(); String hour="" + c.get(Calendar.HOUR_OF_DAY); String min="" + c.get(Calendar.MINUTE); String sec="" + c.get(Calendar.SECOND); if (hour.length() == 1) hour="0" + hour; if (min.length() == 1) min="0" + min; if (sec.length() == 1) sec="0" + sec; return … Read more

The Most Widely Used Java Libraries

Update on 2020/10/07: This list was created nearly 10 years ago. The new list is available here. This article summarizes the most popular and widely used Java libraries for a variety of different applications. 1. Core Apache Commons Lang – Apache’s library that provides a host of helper utilities for the java.lang API, such as … Read more

How to select elements but exclude a string or exclude an element by using JQuery

Here is the code:

<div class="content">
    <a href="#">A</a></div>
<div class="content">
    <a href="#">B</a></div>
<div class="content">
    <a href="#">C</a></div>

Read more