當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Java CharsetDecoder unmappableCharacterAction()用法及代碼示例


unmappableCharacterAction()方法是java.nio.charset.CharsetDecoder類的內置方法,該方法針對unmappable-character錯誤返回此解碼器的當前操作。

用法

public CodingErrorAction unmappableCharacterAction()

參數:該函數不接受任何參數。


返回值:函數會針對unmappable-character錯誤返回此解碼器的當前操作。

下麵是上述函數的實現:

示例1:

// Java program to demonstrate 
// the above function 
  
import java.nio.charset.*; 
import java.util.Iterator; 
import java.util.Map; 
  
public class GFG { 
  
    public static void main(String[] args) 
    { 
  
        // Gets the charset 
        Charset charset = Charset.forName("ISO-2022-CN"); 
  
        // Get the CharsetDecoder 
        CharsetDecoder decoder = charset.newDecoder(); 
  
        // Prints the CharsetDecoder 
        System.out.println("CharsetDecoder: " + decoder); 
  
        System.out.println("Current action for "
                           + "unmappable-character errors: "
                           + decoder.unmappableCharacterAction()); 
    } 
}
輸出:
CharsetDecoder: sun.nio.cs.ext.ISO2022_CN$Decoder@232204a1
Current action for unmappable-character errors: REPORT

示例2:

// Java program to demonstrate 
// the above function 
  
import java.nio.charset.*; 
import java.util.Iterator; 
import java.util.Map; 
  
public class GFG { 
  
    public static void main(String[] args) 
    { 
  
        // Gets the charset 
        Charset charset = Charset.forName("x-windows-949"); 
  
        // Get the CharsetDecoder 
        CharsetDecoder decoder = charset.newDecoder(); 
  
        // Prints the CharsetDecoder 
        System.out.println("CharsetDecoder: " + decoder); 
  
        System.out.println("Current action for "
                           + "unmappable-character errors: "
                           + decoder.unmappableCharacterAction()); 
    } 
}
輸出:
CharsetDecoder: sun.nio.cs.ext.DoubleByte$Decoder@232204a1
Current action for unmappable-character errors: REPORT

參考: https://docs.oracle.com/javase/9/docs/api/java/nio/charset/CharsetDecoder.html#unmappableCharacterAction–



相關用法


注:本文由純淨天空篩選整理自ShubhamMaurya3大神的英文原創作品 CharsetDecoder unmappableCharacterAction() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。