Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #21535

Re: creating byte[] with subfields

From Daniel Pitts <newsgroup.nospam@virtualinfinity.net>
Newsgroups comp.lang.java.programmer
Subject Re: creating byte[] with subfields
References <o62if8p1orppd2poseimactf3rqu0s04kn@4ax.com>
Message-ID <OSgKs.128923$pV4.20397@newsfe21.iad> (permalink)
Date 2013-01-18 10:53 -0800

Show all headers | View raw


On 1/18/13 12:35 AM, Roedy Green wrote:
> 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.
>
How about using a BitSet instead?

Or, avoid this level of low-level work?

Or, create a helper wrapper class. BitStream, where you can write a 
number of bits, rather than whole bytes.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

creating byte[] with subfields Roedy Green <see_website@mindprod.com.invalid> - 2013-01-18 00:35 -0800
  Re: creating byte[] with subfields Jim Janney <jjanney@shell.xmission.com> - 2013-01-18 08:31 -0700
    Re: creating byte[] with subfields Jim Janney <jjanney@shell.xmission.com> - 2013-01-18 10:29 -0700
  Re: creating byte[] with subfields Nigel Wade <nmw@ion.le.ac.uk> - 2013-01-18 16:23 +0000
  Re: creating byte[] with subfields Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-01-18 10:53 -0800
    Re: creating byte[] with subfields Roedy Green <see_website@mindprod.com.invalid> - 2013-01-18 14:23 -0800
      Re: creating byte[] with subfields Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-01-18 15:16 -0800
        Re: creating byte[] with subfields Roedy Green <see_website@mindprod.com.invalid> - 2013-01-18 23:24 -0800
          Re: creating byte[] with subfields Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-01-19 21:46 -0800
            Re: creating byte[] with subfields Joshua Cranmer <Pidgeot18@verizon.invalid> - 2013-01-20 11:01 -0600
              Re: creating byte[] with subfields Arne Vajhøj <arne@vajhoej.dk> - 2013-01-20 12:54 -0500
            Re: creating byte[] with subfields Arne Vajhøj <arne@vajhoej.dk> - 2013-01-20 12:51 -0500
        Re: creating byte[] with subfields Arne Vajhøj <arne@vajhoej.dk> - 2013-01-19 13:34 -0500
  Re: creating byte[] with subfields Arne Vajhøj <arne@vajhoej.dk> - 2013-01-18 20:33 -0500
    Re: creating byte[] with subfields Arne Vajhøj <arne@vajhoej.dk> - 2013-01-18 20:48 -0500

csiph-web