Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Jim Janney Newsgroups: comp.lang.java.programmer Subject: Re: creating byte[] with subfields Date: Fri, 18 Jan 2013 08:31:05 -0700 Organization: a banner with a strange device Lines: 13 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx04.eternal-september.org; posting-host="75975abe3fe3503ca7350803ab98e478"; logging-data="6332"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183ZIhydnl6/ZV6hefcbiwh" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:H9XWoEZpM7GeEhqW8+ndIlfoulU= sha1:D4M4nkv15+YyyV1rOjzHkYj6lDI= Xref: csiph.com comp.lang.java.programmer:21518 Roedy Green writes: > I often have to construct byte arrays with binary fields, or read > them. > > I use a ByteArrayOutputStream and a DataOutputStream to compose them. > I wondered if there is a simpler way, one that does not require > computing each byte individually with shifts. In C, sure. Java by design doesn't allow those kinds of tricks. -- Jim Janney