본문 바로가기

카테고리 없음

java useful

https://introcs.cs.princeton.edu/java/11cheatsheet/

http://javadevnotes.com/java-double-to-string-examples


array copy

 - System.arraycopy


hex string to byte array

 - byte[] bytes = new java.math.BigInteger(hexText, 16).toByteArray();


byte array to hex string

 - String hexText = new java.math.BigInteger(bytes).toString(16);

    public static String toHexString(byte buf[]){

        StringBuffer sb = new StringBuffer();

        for (int i = 0; i < buf.length; i++) {

            sb.append(Integer.toHexString(0x0100 + (buf[i] & 0x00FF)).substring(1));

        }

        return sb.toString();

    }



byte to string

 - String str2 = new String(buffers)


string to byte

 - bytes[] buffers = str1.getBytes();