ToBin.java revision 9330:8b1f1c2a400f
1139749Simp/*
2156000Smjacob * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
3101704Smjacob * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4101704Smjacob *
5101704Smjacob * This code is free software; you can redistribute it and/or modify it
6101704Smjacob * under the terms of the GNU General Public License version 2 only, as
7101704Smjacob * published by the Free Software Foundation.  Oracle designates this
8101704Smjacob * particular file as subject to the "Classpath" exception as provided
9101704Smjacob * by Oracle in the LICENSE file that accompanied this code.
10101704Smjacob *
11101704Smjacob * This code is distributed in the hope that it will be useful, but WITHOUT
12101704Smjacob * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13101704Smjacob * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14101704Smjacob * version 2 for more details (a copy is included in the LICENSE file that
15101704Smjacob * accompanied this code).
16101704Smjacob *
17101704Smjacob * You should have received a copy of the GNU General Public License version
18101704Smjacob * 2 along with this work; if not, write to the Free Software Foundation,
19101704Smjacob * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20101704Smjacob *
21101704Smjacob * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22101704Smjacob * or visit www.oracle.com if you need additional information or have any
23101704Smjacob * questions.
24101704Smjacob */
25101704Smjacob
26101704Smjacobpackage build.tools.icondata.osxapp;
27156000Smjacob
28156000Smjacobimport java.io.*;
29156000Smjacob
30156000Smjacobpublic class ToBin {
31156104Smjacob    public static void main(String[] args) throws Exception {
32156000Smjacob        ByteArrayOutputStream baos = new ByteArrayOutputStream();
33156000Smjacob        int nRead;
34156000Smjacob        byte[] data = new byte[4096];
35156000Smjacob
36156000Smjacob        while ((nRead = System.in.read(data, 0, data.length)) != -1) {
37156000Smjacob            baos.write(data, 0, nRead);
38156000Smjacob        }
39156000Smjacob
40156000Smjacob        baos.flush();
41156000Smjacob
42156000Smjacob        byte[] buf = baos.toByteArray();
43156000Smjacob        for (int i = 0; i < buf.length; i++) {
44156000Smjacob            System.out.print(String.format("0x%1$02X", buf[i]) + ", ");
45156104Smjacob            if (i % 20 == 0) {
46156000Smjacob                System.out.println();
47156000Smjacob            }
48156000Smjacob        }
49156000Smjacob    }
50156000Smjacob}
51156000Smjacob