Skip to content

Instantly share code, notes, and snippets.

View asdf913's full-sized avatar

asdf913

  • Hong Kong
  • Hong Kong
View GitHub Profile
@asdf913
asdf913 / JapaneseEraJPanel.java
Last active August 6, 2026 05:33
Japanese Era Report
import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.text.DateFormat;
import java.text.ParseException;
@asdf913
asdf913 / LocalGregorianCalendarReport.java
Last active August 5, 2026 15:10
LocalGregorianCalendarReport.java
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.OptionalInt;
import java.util.function.Predicate;
@asdf913
asdf913 / JapaneseDateWesternDateSpreadSheet24.java
Last active August 4, 2026 05:46
JapaneseDateWesternDateSpreadSheet (Java 24)
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.classfile.ClassFile;
import java.lang.classfile.ClassFileElement;
import java.lang.classfile.ClassModel;
import java.lang.classfile.CodeElement;
import java.lang.classfile.CodeModel;
@asdf913
asdf913 / UpdateVersion.java
Created June 18, 2026 02:57
UpdateVersion - Program to update maven dependency version for a specified pom.xml file
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import javax.xml.stream.Location;
@asdf913
asdf913 / BiosUtil.java
Last active June 1, 2026 14:35
How to get the BIOS vendor under Linux,MacOSX and Microsoft Windows by Java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.util.Collection;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@asdf913
asdf913 / XlsxUtil.java
Last active May 18, 2026 01:47
Method to detect a byte array is a valid XLSX data or not
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Base64;
import java.util.Base64.Decoder;
import java.util.Objects;
@asdf913
asdf913 / ProcessIdPortMultimap.java
Created May 8, 2026 07:30
Get the mulitmap of Process Id and it opened port number.
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystems;
import java.util.List;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.collections4.IterableUtils;
@asdf913
asdf913 / StringArrayToMap.java
Created May 8, 2026 01:12
Convert a String array into a java.util.Map
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
public class StringArrayToMap {
@asdf913
asdf913 / InetSocketAddressCheckPort.class
Created May 7, 2026 12:59
Retrieve the allowed minimum and maximum port number defined in "checkPort()" in "java.net.InetSocketAddress" class
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.InetSocketAddress;
import java.util.Arrays;
import org.apache.bcel.classfile.ClassParser;
import org.apache.bcel.classfile.ConstantPool;
import org.apache.bcel.classfile.FieldOrMethod;
import org.apache.bcel.classfile.JavaClass;
@asdf913
asdf913 / WhichOrWhere.java
Last active May 7, 2026 10:15
Use "which" or "where" to determine if a command is valid. Also print the path of the corresponding executable of the command. Print the actual path if the path is a link
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystems;
import java.util.Objects;
import java.util.function.Predicate;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;