Re: Byte array
Dirk Bruere at NeoPax wrote:
Knute Johnson wrote:
Dirk Bruere at NeoPax wrote:
Dirk Bruere at NeoPax wrote:
I need to fill a predefined byte array with hexadecimal bytes.
I can do it like this:
public static byte[] default0 = { (byte)0x87, (byte)0x3f,
... };
By casting each value.
Which is a bit of a pain considering I have to copy and paste from
an existing text source of hex bytes (about 20,000 bytes).
Is there a representation I can use such that I do not need to cast
each one individually?
Thanks for the replies.
The original text was a Windows .reg file, so it's got to be a cut
and paste job. Good news is that its all plain text comma separated.
One other question - any way I can get the array to see the text
input as hex rather than decimal by default? Otherwise I have to add
"0x" to each entry. Not a vast deal given my text editor, but I'd
rather not.
Dirk:
What's the file look like? Maybe there is a simple conversion that
you can use from the text.
Here's a line of it with a continuation backslash ending each line:
00,02,00,00,6e,06,00,00,00,00,00,00,58,50,43,52,01,00,10,00,01,5e,06,00,00,\
Right now I'm just using a macro on a text editor to reformat it. No big
problem.
Look at the Scanner class. You can read the data directly into a byte,
write it into a ByteArrayInputStream and then get a byte[] from that.
--
Knute Johnson
email s/nospam/knute2009/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access