malformedInputAction()方法是java.nio.charset.CharsetDecoder類的內置方法,該方法針對malformed-input錯誤返回此解碼器的當前操作。
用法:
public CodingErrorAction malformedInputAction()
參數:該函數不接受任何參數。
返回值:函數會針對malformed-input錯誤返回此解碼器的當前操作。
下麵是上述函數的實現:
示例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 "
+ "malformed-input errors: "
+ decoder.malformedInputAction());
}
}
輸出:
CharsetDecoder: sun.nio.cs.ext.ISO2022_CN$Decoder@232204a1 Current action for malformed-input 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 "
+ "malformed-input errors: "
+ decoder.malformedInputAction());
}
}
輸出:
CharsetDecoder: sun.nio.cs.ext.DoubleByte$Decoder@232204a1 Current action for malformed-input errors: REPORT
參考: https://docs.oracle.com/javase/9/docs/api/java/nio/charset/CharsetDecoder.html#malformedInputAction–
相關用法
- Java CharsetEncoder malformedInputAction()用法及代碼示例
- Java CharsetDecoder isCharsetDetected()用法及代碼示例
- Java CharsetDecoder reset()用法及代碼示例
- Java CharsetDecoder unmappableCharacterAction()用法及代碼示例
- Java CharsetDecoder averageCharsPerByte()用法及代碼示例
- Java CharsetDecoder detectedCharset()用法及代碼示例
- Java CharsetDecoder isAutoDetecting()用法及代碼示例
- Java CharsetDecoder maxCharsPerByte()用法及代碼示例
- Java CharsetDecoder replacement()用法及代碼示例
- Java CharsetDecoder charset()用法及代碼示例
- Java Java.util.Collections.rotate()用法及代碼示例
- Java Java lang.Long.byteValue()用法及代碼示例
- Java Java lang.Long.reverse()用法及代碼示例
- Java Java.util.Collections.disjoint()用法及代碼示例
- Java Java lang.Long.builtcount()用法及代碼示例
注:本文由純淨天空篩選整理自ShubhamMaurya3大神的英文原創作品 CharsetDecoder malformedInputAction() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。