從1中取2的交集,移除所有存在1中但不存在于2中的記錄
list1.retainAll(list2);
調(diào)用默認(rèn)瀏覽器打開指定網(wǎng)址
try {
Desktop d = Desktop.getDesktop();
URI u = new URI("www.baidu.com");
d.browse(u);
} catch (Exception e) {
e.printStackTrace();
}
讀取yaml配置文件,Yaml相關(guān)的庫來自org.yaml.snakeyaml
Yaml yaml = new Yaml();
try (InputStream inputStream = AnyClass.class
.getClassLoader()
.getResourceAsStream("application.yml")) {
Map<String, Object> obj = yaml.load(inputStream);
obj.forEach((k, v) -> {
System.out.println(k + "|type" + v.getClass() + "|" + GsonUtil.getInstance().toJson(v));
});
}
如何處理InterruptException
public void run() {
try {
while (true) {
// do stuff
}
} catch (InterruptedException e) {
// record a log
// Restore interrupted state...
Thread.currentThread().interrupt();
}
}