public static boolean isCompressed(final byte[] compressed) {
        return (compressed[0== (byte) (GZIPInputStream.GZIP_MAGIC)) && (compressed[1== (byte) (GZIPInputStream.GZIP_MAGIC >> 8));
    }
    
    public static byte[] compress(final String str) throws IOException {
        if ((str == null|| (str.length() == 0)) {
            return null;
        }
        ByteArrayOutputStream obj = new ByteArrayOutputStream();
        GZIPOutputStream gzip = new GZIPOutputStream(obj);
        gzip.write(str.getBytes("UTF-8"));
        gzip.close();
        //System.out.println(obj.toByteArray()[1]);
        return obj.toByteArray();
    }
    
    public static String packetDecompress(final String msg){
        //byte[] bcdz = compress("asdasdz");
        //System.out.println(decompress(bcdz));
        //System.out.println(bcdz[0]);
        
        //String ad = "{\"type\":\"Buffer\",\"data\":[31,139,8,0,0,0,0,0,0,0,99,9,73,18,16,22,101,9,73,150,20,148,100,9,73,18,73,73,66,99,139,37,139,130,216,146,169,44,68,171,140,70,85,74,138,162,81,27,6,129,13,20,184,108,184,42,194,46,1,0,199,90,197,78,61,3,0,0]}";
        //ad = "[31,-117,8,0,0,0,0,0,0,0,75,44,78,73,44,78,-87,2,0,35,70,-59,53,7,0,0,0,0,0,0,0,0]";
        //ad = "[31,139,8,0,0,0,0,0,0,0,99,9,73,18,16,22,101,9,73,18,145,76,141,102,129,114,146,37,5,37,1,247,124,130,131,25,0,0,0]";
        String[] tmp;
        int lastPos = 0, pos = 0;   
        pos = msg.indexOf("[");
        lastPos = msg.indexOf("]");
        String msg2 = msg.substring(pos+1, lastPos);
        //System.out.println(ad);
        tmp = msg2.split(",");
        byte[] bytes = new byte[tmp.length];
        for(int i=0;i<tmp.length;i++){
            if(Integer.valueOf(tmp[i]) > 127) bytes[i] = (byte) (Integer.valueOf(tmp[i])+256); // -128 ~ 127 자바 byte 타입 범위
            else bytes[i] = Byte.valueOf(tmp[i]);
        }
        try {
            return XorDecryption(decompress(bytes));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "NULL";
        /*System.out.println(decompress(bytes));
        System.out.println(XorDecryption(decompress(bytes)));
        System.out.println(tmp.length);*/
    }
 
    public static String decompress(final byte[] compressed) throws IOException {
        String outStr = "";
        if ((compressed == null|| (compressed.length == 0)) {
            return "";
        }
        if (isCompressed(compressed)) {
            GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(compressed));
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(gis, "UTF-8"));
 
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                outStr += line;
            }
        } else {
            //outStr = new String(compressed);
            outStr = "HACKING";
        }
        return outStr;
    }
    


'Java' 카테고리의 다른 글

java 참고  (0) 2019.01.17
웹페이지를 PDF로 변환하는 라이브러리 +pdf 관련 자바 라이브러리  (0) 2017.09.27
자바 참고학습  (0) 2017.07.20
자바강의  (0) 2017.01.03

 현재 주간current week의 첫번째 날

TRUNC(sysdate,'IW')

2. 이전 주간prior week의 첫번째 날

TRUNC(sysdate-7,'IW')

3. 다음 주간next week의 첫번째 날

NEXT_DAY(sysdate,'MONDAY')

4. 현재 달current month의 첫번째 날

TRUNC(sysdate,'MM')

5. 이전 달prior month의 첫번째 날

ADD_MONTHS( TRUNC(sysdate,'MM'), -1 )

6. 다음 달next month의 첫번째 날

ADD_MONTHS( TRUNC(sysdate,'MM'), 1 )

7. 현재 달current month의 마지막 날

LAST_DAY(sysdate)




ISSUE : to_char(add_mnths(sysdate,-1),'YYYYMMDD')


FUNCTION : add_month(날짜, +(or -) 개월수)




한달 전 예제  select to_char(add_months(sysdate, -1),'yyyymmddhh24miss') from dual;


한달 후 예제  select to_char(add_months(sysdate, 1),'yyyymmddhh24miss') from dual;



출처 : http://qqqqqq.tistory.com/entry/%EC%98%A4%EB%9D%BC%ED%81%B4-%EB%82%A0%EC%A7%9C-%EC%9B%94-%EB%8D%94%ED%95%98%EA%B8%B0-%EB%B9%BC%EA%B8%B0-addmonth

+ Recent posts