Java: parse octal number from string and format string to represent octal number








        int mode = Integer.parseInt("0644", 8);
        System.out.println(String.format("%04o", mode));



Split large file and assemble the parts








split -b 256mb large-file.tgz large-file.tgz.
cat large-file.tgz.* > /path/to/output/large-file.tgz



Thread-safe, fixed-size map remove the eldest element automatically








    public static final int MAX_SIZE = 1000;
    Map map = Collections.synchronizedMap(new LinkedHashMap() {
       private static final long serialVersionUID = 12345L; 
       @Override
       protected boolean removeEldestEntry(Entry eldest) {
           return size() > MAX_SIZE;
       }               
    });



See also stackoverflow

  • https://stackoverflow.com/a/28654664
  • https://stackoverflow.com/a/1963881