Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
CharsetEncoder replacement() method in Java with Examples
Next article icon

CharsetDecoder reset() method in Java with Examples

Last Updated : 27 Jun, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

The reset() method is a built-in method of the java.nio.charset.CharsetDecoder class which resets this CharsetDecoder and clears its internal state.

Syntax:

public final CharsetDecoder reset()

Parameters: The function does not accepts any parameter.

Return Value: The function returns this CharsetDecoder after resetting it.

Below is the implementation of the above function:

Program 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());
    }
}
 
 
Output:
  Before reset: sun.nio.cs.ext.ISO2022_CN$Decoder@232204a1  After reset: sun.nio.cs.ext.ISO2022_CN$Decoder@232204a1  

Program 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());
    }
}
 
 
Output:
  Before reset: sun.nio.cs.ext.DoubleByte$Decoder@232204a1  After reset: sun.nio.cs.ext.DoubleByte$Decoder@232204a1  

Reference: https://docs.oracle.com/javase/9/docs/api/java/nio/charset/CharsetDecoder.html#reset–



Next Article
CharsetEncoder replacement() method in Java with Examples

S

ShubhamMaurya3
Improve
Article Tags :
  • Java
  • Java-CharsetDecoder
  • Java-Functions
  • Java-nio-charset package
Practice Tags :
  • Java

Similar Reads

  • CharsetEncoder reset() method in Java with Examples
    The reset() method is a built-in method of the java.nio.charset.CharsetEncoder resets this encoder, and clears all the internal states if there are any. It also resets charset-independent state and also invokes the implReset method in order to perform any charset-specific reset actions. Syntax: publ
    2 min read
  • CharsetDecoder replacement() method in Java with Examples
    The replacement() method is a built-in method of the java.nio.charset.CharsetDecoder class returns this decoder's replacement value. The replacement value needs to be set inorder to get a valid replacement value. Syntax: public final Charset replacement() Parameters: The function does not accepts an
    1 min read
  • CharsetEncoder replacement() method in Java with Examples
    The replacement() method is a built-in method of the java.nio.charset.CharsetEncoder returns a byte array which is the replacement value of the encoder. Syntax: public final byte[] replacement() Parameters: The function does not accepts any parameter. Return Value: The function returns this encoder'
    1 min read
  • CharArrayReader reset() method in Java with Examples
    The reset() method of CharArrayReader Class in Java is used to reset the stream. After reset, if the stream has been marked, then this method attempts to reposition it at the mark, else it will try to position it to the starting. Syntax: public void reset() Parameters: This method do not accepts any
    3 min read
  • CharBuffer reset() methods in Java with Examples
    The reset() method of java.nio.CharBuffer Class is used to reset this buffer's position to the previously-marked position. Invoking this method neither changes nor discards the mark's value. Syntax: public final CharBuffer reset() Return Value: This method returns this buffer. Below are the examples
    2 min read
  • BufferedReader reset() method in Java with Examples
    The reset() method of BufferedReader class in Java is used to fix or mark the position at the last marked position so that the same byte can be read again. Syntax: public void reset() throws IOException Overrides: It overrides the reset() method of Reader class. Parameters: The method does not accep
    3 min read
  • Matcher reset(CharSequence) method in Java with Examples
    The reset(CharSequence input) method of Matcher Class is used to reset this matcher and insert the input String passed as the parameter to this matcher. Syntax: public Matcher reset(CharSequence input) Parameters: This method takes the parameter input which is the String to be inserted into matcher
    2 min read
  • CharsetEncoder charset() method in Java with Examples
    The charset() method is a built-in method of the java.nio.charset.CharsetEncoder returns the charset that created this encoder. Syntax: public final Charset charset() Parameters: The function does not accepts any parameter. Return Value: The function returns this encoder's charset. Below is the impl
    1 min read
  • DoubleAdder reset() method in Java with Examples
    The java.DoubleAdder.reset() is an inbuilt method in java that resets variables maintaining the sum to zero. When the object of the class is created its initial value is zero. Syntax: public void reset() Parameters: This method does not accepts any parameter. Return Value: The method returns the res
    1 min read
  • Charset name() method in Java with Examples
    The name() method is a built-in method of the java.nio.charset returns the charset's canonical name. Syntax: public final String name() Parameters: The function does not accepts any parameter. Return Value: The function returns the charset's canonical name. Below is the implementation of the above f
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences