Java : UnsupportedEncodingException with Examples
UnsupportedEncodingException (Java SE 23 & JDK 23) in Java with Examples.
You will find code samples for most of the UnsupportedEncodingException methods.
Summary
The Character Encoding is not supported.
try {
final var ret = "abc".getBytes("Shift_JIS");
System.out.println(Arrays.toString(ret));
} catch (UnsupportedEncodingException e) {
System.out.println("UnsupportedEncodingException!");
}
// Result
// ↓
//[97, 98, 99]
try {
final var ret = "abc".getBytes("XXX");
System.out.println(Arrays.toString(ret));
} catch (UnsupportedEncodingException e) {
System.out.println("UnsupportedEncodingException!");
}
// Result
// ↓
//UnsupportedEncodingException!
Constructors
UnsupportedEncodingException ()
Constructs an UnsupportedEncodingException without a detail message.
final var e = new UnsupportedEncodingException();
System.out.println(e); // java.io.UnsupportedEncodingException
UnsupportedEncodingException (String s)
Constructs an UnsupportedEncodingException with a detail message.
final var e = new UnsupportedEncodingException("abc");
System.out.println(e); // java.io.UnsupportedEncodingException: abc
System.out.println(e.getMessage()); // abc
Methods declared in Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Please see the link below.
Related posts
- API Examples
- Error
- Exception
- RuntimeException
- ArithmeticException
- ArrayIndexOutOfBoundsException
- ArrayStoreException
- BufferOverflowException
- BufferUnderflowException
- CancellationException
- ClassCastException
- ConcurrentModificationException
- DateTimeException
- DateTimeParseException
- IllegalArgumentException
- IllegalStateException
- IndexOutOfBoundsException
- NoSuchElementException
- NullPointerException
- PatternSyntaxException
- ReadOnlyBufferException
- StringIndexOutOfBoundsException
- UnsupportedOperationException
- Throwable