I write things that I often use Java but can't remember.
for (Map.Entry<String, String> entry : map.entrySet())
String[] str = new String[3];
String[] str = { "aaa", "bbb", "ccc" };
org.apache.commons.lang3.ArrayUtils.addAll(Array 1,Array 2);
if (Arrays.asList("aaa", "bbb").contains(String to compare)) {}
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
String line;
while ((line = br.readLine()) != null) {
}
}
String str = "aaa-bbb-ccc-ddd";
Pattern p = Pattern.compile("^aaa-(.*)-(.*)-ddd$");
Matcher m = p.matcher(str);
if (m.find()) {
System.out.println(m.group(1)); // bbb
System.out.println(m.group(2)); // ccc
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
Date date = sdf.parse("2018/01/01 10:00:00.000");
String dateStr = sdf.format(date);
String.format
//Zero padding
String.format("%05d", 1); // 00005
String.format("%02d", 1); // 01
@Override
public String toString() {
return org.apache.commons.lang3.builder.ReflectionToStringBuilder.toString(this);
}
The arrangement of HashMap k = v is appropriate. high speed Hashtable key is in descending order TreeMap key is in ascending order LinkedHashMap Arrange in the order in which k = v is entered. If you want to make a Map into a List, you should make it with this
Increase memory. -Xmx3072m -Xms512m
https://paiza.io/ja/projects/new
If you use throw e in the catch clause, the stack trace information will be lost, so wrap it in another exception such as throw new XXXException ("", e) and throw it.
Recommended Posts