bin2hex
? Java ??????,?????????????????????????????,????????????????????????????,?????????????????? bin2hex
???
??????????,??????? Java ?????????????:
import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; public class Bin2HexBatchConversion { public static void main(String[] args) { ListinputStrings = new ArrayList<>(); inputStrings.add("Hello"); inputStrings.add("World"); inputStrings.add("Java"); List hexStrings = batchConvertBinToHex(inputStrings); for (String hexString : hexStrings) { System.out.println(hexString); } } public static List batchConvertBinToHex(List inputStrings) { List hexStrings = new ArrayList<>(); for (String inputString : inputStrings) { byte[] inputBytes = inputString.getBytes(StandardCharsets.UTF_8); String hexString = bytesToHex(inputBytes); hexStrings.add(hexString); } return hexStrings; } public static String bytesToHex(byte[] bytes) { StringBuilder sb = new StringBuilder(); for (byte b : bytes) { sb.append(String.format("x", b)); } return sb.toString(); } }
??????,????????????????? inputStrings
,???? batchConvertBinToHex
???????????????????batchConvertBinToHex
???????????????? bytesToHex
?????,????????????????????? hexStrings
?????