From b6c1cf6de79035f58b512f4400db458c8401379a Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 21 Oct 2008 07:00:00 -0700 Subject: Initial Contribution --- libs/host/list.java | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 libs/host/list.java (limited to 'libs/host/list.java') diff --git a/libs/host/list.java b/libs/host/list.java new file mode 100644 index 0000000..30546e3 --- /dev/null +++ b/libs/host/list.java @@ -0,0 +1,35 @@ +import java.io.*; + +public class list { + private static char nibble(int c) { + return (char)(c < 10 ? ('0' + c) : ('a' + (c-10))); + } + public static void main(String[] argv) + { + ByteArrayOutputStream stream = new ByteArrayOutputStream(100); + OutputStreamWriter writer = null; + try { + writer = new OutputStreamWriter(stream, "utf-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(System.err); + } + + int n = Integer.parseInt(argv[1], 16); + try { + writer.write(n); + writer.close(); + } catch (IOException e) { + e.printStackTrace(System.err); + } + + byte[] array = stream.toByteArray(); + + System.out.print(" case '" + argv[0] + "': return \""); + for (int i=0; i> 4) & 0x0f) + nibble(b & 0xf)); + } + System.out.println("\";"); + } +} + -- cgit v1.1