java tutorial - Java Strings getBytes() method - java programming - learn java - java basics - java for beginners
Learn Java - Java tutorial - Java strings getbytes - Java examples - Java programs
Description
The method getBytes () in Java has two forms:
- getBytes (String charsetName) - it encodes this string into a byte sequence using charsetName (encoding), stores the result in a new byte array.
- getBytes () - it encodes this string into a byte sequence, by default using the charset platform, stores the result in a new byte array.
Syntax
The syntax of the method is:
Options
Detailed information about the parameters:
- charsetName - the name of the supported encodings.
Return value
- In Java, getBytes () returns the resultant byte array.