UnsupportedEncodingException
thrown when the Character Encoding is not supported.
import java.nio.charset.*; import java.util.*; import java.io.UnsupportedEncodingException; class StringConstructor6Unsupport{ public static void main(String args[])throws UnsupportedEncodingException{ byte data[] = new byte[26]; String s1; String charSet = "abcd"; int count = 0; for(byte b = 97; b < 123; b++){ data[count] = b; count++; } s1 = new String(data, 5, 10, charSet); System.out.println(s1); } }
Output
Exception in thread "main" java.io.UnsupportedEncodingException: abcd at java.lang.StringCoding.decode(StringCoding.java:190) at java.lang.String.<init>(String.java:414) at StringConstructor6Unsupport.main(StringConstructor6Unsupport.java:17)
No comments:
Post a Comment