reset()方法是java.nio.charset.CharsetDecoder類的內置方法,該方法將重置此CharsetDecoder並清除其內部狀態。
用法:
public final CharsetDecoder reset()
參數:該函數不接受任何參數。
返回值:函數將其重置後返回此CharsetDecoder。
下麵是上述函數的實現:
示例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("Before reset: "
+ decoder);
// Reset the CharsetDecoder
System.out.println("After reset: "
+ decoder.reset());
}
}
輸出:
Before reset: sun.nio.cs.ext.ISO2022_CN$Decoder@232204a1 After reset: sun.nio.cs.ext.ISO2022_CN$Decoder@232204a1
示例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("Before reset: "
+ decoder);
// Reset the CharsetDecoder
System.out.println("After reset: "
+ decoder.reset());
}
}
輸出:
Before reset: sun.nio.cs.ext.DoubleByte$Decoder@232204a1 After reset: sun.nio.cs.ext.DoubleByte$Decoder@232204a1
參考: https://docs.oracle.com/javase/9/docs/api/java/nio/charset/CharsetDecoder.html#reset–
相關用法
- Java CharsetDecoder replacement()用法及代碼示例
- Java CharsetDecoder unmappableCharacterAction()用法及代碼示例
- Java CharsetDecoder detectedCharset()用法及代碼示例
- Java CharsetDecoder isCharsetDetected()用法及代碼示例
- Java CharsetDecoder maxCharsPerByte()用法及代碼示例
- Java CharsetDecoder isAutoDetecting()用法及代碼示例
- Java CharsetDecoder averageCharsPerByte()用法及代碼示例
- Java CharsetDecoder malformedInputAction()用法及代碼示例
- Java Matcher reset()用法及代碼示例
- Java CharArrayWriter reset()用法及代碼示例
- Java PushbackReader reset()用法及代碼示例
- Java LogManager reset()用法及代碼示例
- Java LongBuffer reset()用法及代碼示例
- Java MessageDigest reset()用法及代碼示例
- Java CollationElementIterator reset()用法及代碼示例
注:本文由純淨天空篩選整理自ShubhamMaurya3大神的英文原創作品 CharsetDecoder reset() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。