Java : UnsupportedEncodingException con ejemplos

UnsupportedEncodingException (Java SE 23 & JDK 23) en Java con ejemplos.
Encontrará muestras de código para la mayoría de los métodos UnsupportedEncodingException.

Nota :


Summary

La codificación de caracteres no es compatible. (Traducción automática)

Class diagram

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 ()

Construye una UnsupportedEncodingException sin un mensaje detallado. (Traducción automática)

final var e = new UnsupportedEncodingException();
System.out.println(e); // java.io.UnsupportedEncodingException

UnsupportedEncodingException (String s)

Construye una UnsupportedEncodingException con un mensaje detallado. (Traducción automática)

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

Consulte el siguiente enlace.


Related posts

To top of page