Scala String getBytes() method with example
The getBytes() method is utilized to encode a stated string into a series of bytes and then it stores it into a new byte array. Moreover, here platforms default charset is utilized.
Method Definition: byte getBytes()
Return Type: It returns a new byte array storing series of bytes.
Example #1:
object GfG
{
def main(args : Array[String])
{
val result = "Nidhi" .getBytes()
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val result = " " .getBytes()
println(result)
}
}
|
Last Updated :
03 Oct, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...