2:55 am - Friday April 19, 2019

Encode given string to byte array byte[ ] getBytes[ ]

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

                   This function encodes the given string into a sequence of bytes using default character set and stores the new byte value in another byte array.

Example Program

public class Byte1 {

	public static void main(String[] args)

	{

		String s1 = "BYTE VALUE";

		System.out.println(s1);

		byte[] b = s1.getBytes();

		System.out.println(b);

	}

}

Output

   BYTE VALUE

    [B@1f33675

Description

         Here the string s1 have the value and it is encoded into a sequence of bytes using the default character set and store the encoded result in a new byte b.

Filed in: Java Examples

Comments are closed.