1 2 3 | Byte[] bytes = (Byte[]) arrayList.toArray(); // ArrayList -> Byte[] arrayList = new ArrayList(Arrays.asList(bytes )); // Byte[] -> ArrayList | cs |
(만약 프리미티브 byte[]로 전환하고자 하신다면, Bytes[X].byteValue() 를 X값을 루프를 돌면서 복사해주면됩니다.)
출처 : http://mungi.kr/177
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | int Decint = Integer.parseInt(Dec); byte [] bytes = {0x00,0x00}; String hexto04=""; String hex = Integer.toHexString(Decint); if(Decint<0) { hexto04 = hex.substring(hex.length()-4); bytes = new java.math.BigInteger(hexto04,16).toByteArray(); } else if(Decint>0) { bytes = new java.math.BigInteger(hex,16).toByteArray(); } return bytes ; | cs |
출처 : http://ecogeo.tistory.com/129
위의 hexString to byte 같은 경우 음수가 들어오면 변환은 내가 대충 짜본것이다.
추가
wrapper 가 아닌 primetive byte[] 전환
1 2 3 4 | byte [] bytes = new byte[sendbyte.size()]; for (int i = 0 ; i<sendbyte.size();i++){ bytes[i]= sendbyte.get(i); } | cs |
'자바' 카테고리의 다른 글
Git server에서 프로젝트 가져오기 (0) | 2015.12.10 |
---|---|
이클립스에서의 프로젝트 공유, 등록 (0) | 2015.12.10 |
synology에 git 설정중 나에게 필요한부분 (0) | 2015.12.10 |
자바 프로퍼티 예제 (출처 http://notgivuphil.tistory.com/505#rp ) (0) | 2015.10.23 |
자바(JAVA)에서 CTRL+C를 누르거나 프로그램 종료 시 특정 작업 수행 하기 [출처] 오라클자바커뮤니티 (0) | 2015.10.23 |