4 private static char nibble(int c) {
5 return (char)(c < 10 ? ('0' + c) : ('a' + (c-10)));
7 public static void main(String[] argv)
9 ByteArrayOutputStream stream = new ByteArrayOutputStream(100);
10 OutputStreamWriter writer = null;
12 writer = new OutputStreamWriter(stream, "utf-8");
13 } catch (UnsupportedEncodingException e) {
14 e.printStackTrace(System.err);
17 int n = Integer.parseInt(argv[1], 16);
21 } catch (IOException e) {
22 e.printStackTrace(System.err);
25 byte[] array = stream.toByteArray();
27 System.out.print(" case '" + argv[0] + "': return \"");
28 for (int i=0; i<array.length; i++) {
30 System.out.print("\\x" + nibble((b >> 4) & 0x0f) + nibble(b & 0xf));
32 System.out.println("\";");