1 32 33 package com.jeantessier.dependencyfinder; 34 35 import java.io.*; 36 import java.util.*; 37 38 public final class Hex { 39 private Hex() { 40 } 42 43 public static void print(PrintStream out, byte[] bytes) { 44 for (int i=0; i<bytes.length; i++) { 45 print(out, bytes[i]); 46 } 47 } 48 49 public static void print(PrintWriter out, byte[] bytes) { 50 for (int i=0; i<bytes.length; i++) { 51 print(out, bytes[i]); 52 } 53 } 54 55 public static void print(PrintStream out, byte b) { 56 int highBits = (b & 0xF0) >> 4; 57 int lowBits = (b & 0x0F); 58 59 print(out, highBits); 60 print(out, lowBits); 61 } 62 63 public static void print(PrintWriter out, byte b) { 64 int highBits = (b & 0xF0) >> 4; 65 int lowBits = (b & 0x0F); 66 67 print(out, highBits); 68 print(out, lowBits); 69 } 70 71 public static void print(PrintStream out, int n) { 72 out.print(toHexChar(n)); 73 } 74 75 public static void print(PrintWriter out, int n) { 76 out.print(toHexChar(n)); 77 } 78 79 public static String toHexChar(int n) { 80 return Integer.toHexString(n).toUpperCase(); 81 } 82 } 83 | Popular Tags |