How to clear textarea's default text

Often there may be requirements that a html form with a textarea containing a default text clears automatically when someone selects/clicks on the textarea.
This is achieved as below.




How to convert Byte[] array to String in Java

In some cases, we have to convert String variable into a Byte array format, for example, JCE encryption. However how do we convert a Byte[] array to String afterward?

Simple toString() function like following code is not working property. It will not display the original text but byte value.

String s = bytes.toString();

In order to convert Byte array into String format correctly, we have to explicitly create a String object and assign the Byte array to it.

public class TestByte
{
public static void main(String[] argv) {

String example = "This is an example";
byte[] bytes = example.getBytes();

System.out.println("Text : " + example);
System.out.println("Text [Byte Format] : " + bytes);
System.out.println("Text [Byte Format] : " + bytes.toString());

String s = new String(bytes);
System.out.println("Text Decryted : " + s);
}
}