MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / format

Method format

strings/Hex.java:11–23  ·  view source on GitHub ↗
(byte[] data)

Source from the content-addressed store, hash-verified

9
10public class Hex {
11 public static String format(byte[] data) {
12 StringBuilder result = new StringBuilder();
13 int n = 0;
14 for(byte b : data) {
15 if(n % 16 == 0)
16 result.append(String.format("%05X: ", n));
17 result.append(String.format("%02X ", b));
18 n++;
19 if(n % 16 == 0) result.append("\n");
20 }
21 result.append("\n");
22 return result.toString();
23 }
24 public static void
25 main(String[] args) throws Exception {
26 if(args.length == 0)

Callers 15

mainMethod · 0.95
moveMethod · 0.45
mainMethod · 0.45
DatabaseExceptionMethod · 0.45
ReceiptBuilderMethod · 0.45
addMethod · 0.45
buildMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45
toStringMethod · 0.45

Calls 2

appendMethod · 0.80
toStringMethod · 0.45

Tested by 1

mainMethod · 0.36