/****************************************************************************** * This program converts input stream of bytes to hexadecimal. * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ import org.pureprogrammer.Utils; public class HexadecimalFilterByteCount { public static void main(String[] args) { int c; String hex; int count = 0; while ((c = Utils.getbyte(System.in)) != -1) { if (count % 16 == 0) { System.out.print(Utils.format("{0:06x}:", count)); } ++count; hex = Utils.format(" {0:02x}", c); System.out.print(hex); if (count % 16 == 0) { System.out.println(); } } } }