diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:28:42 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:28:42 -0800 |
commit | 88b607994a148f4af5bffee163e39ce8296750c6 (patch) | |
tree | fa249ff843e976cf034f2029437d3362a8396321 /libs/host/list.java | |
parent | 05806d7af62e07c6225b2e7103a1b115ecf6c9ad (diff) | |
download | build-88b607994a148f4af5bffee163e39ce8296750c6.zip build-88b607994a148f4af5bffee163e39ce8296750c6.tar.gz build-88b607994a148f4af5bffee163e39ce8296750c6.tar.bz2 |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'libs/host/list.java')
-rw-r--r-- | libs/host/list.java | 35 |
1 files changed, 35 insertions, 0 deletions
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<array.length; i++) { + int b = array[i]; + System.out.print("\\x" + nibble((b >> 4) & 0x0f) + nibble(b & 0xf)); + } + System.out.println("\";"); + } +} + |