How do I convert a number (as a String) to an array of bytes in Java?
Posted
by
user1795595
on Stack Overflow
See other posts from Stack Overflow
or by user1795595
Published on 2012-11-02T22:43:05Z
Indexed on
2012/11/02
23:00 UTC
Read the original article
Hit count: 147
I'm creating a method specific method for a java project i'm working on.
The UML given specifies the return type to be of static byte[]
that accepts the arguments (String, byte)
So far, looks like this:
public static byte[] convertNumToDigitArray(String number, byte numDigits) {
}
This method is supposed to convert a number (as a String) to an array of bytes. The ordering must go from most to least significant digits. For example, if the
number String is “732” then index 0 of the array should contain 7.
The last argument (numDigits) should match the length of the
string passed in.
How do I do this?
© Stack Overflow or respective owner