Java tutorial
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { private static int[] getSnrAndChannelData(String snr, String channel) { List<Integer> dateItem = new ArrayList(); int intSrn = Integer.valueOf(snr) * 100; String hexSnr = Integer.toHexString(intSrn); if (hexSnr.length() < 4) { switch (hexSnr.length()) { case 1: hexSnr = "000" + hexSnr; break; case 2: hexSnr = "00" + hexSnr; break; case 3: hexSnr = "0" + hexSnr; break; } } dateItem.add(Integer.valueOf(hexSnr.substring(2, 4), 16)); dateItem.add(Integer.valueOf(hexSnr.substring(0, 2), 16)); for (int i = 0; i < 6; i++) { dateItem.add(0); } String hexChannel = Integer.toHexString(Integer.valueOf(channel)); if (hexChannel.length() < 4) { switch (hexChannel.length()) { case 1: hexChannel = "000" + hexChannel; break; case 2: hexChannel = "00" + hexChannel; break; case 3: hexChannel = "0" + hexChannel; break; } } dateItem.add(Integer.valueOf(hexChannel.substring(2, 4), 16)); dateItem.add(Integer.valueOf(hexChannel.substring(0, 2), 16)); for (int i = 0; i < 7; i++) { dateItem.add(0); } int[] message = new int[dateItem.size()]; for (int i = 0; i < dateItem.size(); i++) { // Logs.e("dateItem" + i + "===" + dateItem.get(i)); message[i] = dateItem.get(i); } return message; } }