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:
CharsetDecoder unmappableCharacterAction() method in Java with Examples
Next article icon

CharsetDecoder replacement() method in Java with Examples

Last Updated : 27 Jun, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
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 any parameter. Return Value: The function returns this decoder's replacement value. Below is the implementation of the above function: Program 1: Java
// 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("Replacement Value: "                            + decoder.replacement());     } } 
Output:
  CharsetDecoder: sun.nio.cs.ext.ISO2022_CN$Decoder@232204a1  Replacement Value: ?  
Program 2: Java
// 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("Replacement Value: "                            + decoder.replacement());     } } 
Output:
  CharsetDecoder: sun.nio.cs.ext.DoubleByte$Decoder@232204a1  Replacement Value: ?  
Reference: https://docs.oracle.com/javase/9/docs/api/java/nio/charset/CharsetDecoder.html#replacement--

Next Article
CharsetDecoder unmappableCharacterAction() method in Java with Examples

S

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

Similar Reads

  • 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
  • CharsetDecoder reset() method in Java with Examples
    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 CharsetDec
    1 min read
  • 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
  • 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
  • CharsetDecoder unmappableCharacterAction() method in Java with Examples
    The unmappableCharacterAction() method is a built-in method of the java.nio.charset.CharsetDecoder class which returns this decoder's current action for unmappable-character errors. Syntax: public CodingErrorAction unmappableCharacterAction() Parameters: The function does not accepts any parameter.
    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
  • 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
  • CharsetDecoder malformedInputAction() method in Java with Examples
    The malformedInputAction() method is a built-in method of the java.nio.charset.CharsetDecoder class which returns this decoder's current action for malformed-input errors. Syntax: public CodingErrorAction malformedInputAction() Parameters: The function does not accepts any parameter. Return Value: T
    1 min read
  • CharsetDecoder maxCharsPerByte() method in Java with Examples
    The maxCharsPerByte() method is a built-in method of the java.nio.charset.CharsetDecoder class which returns the maximum number of characters that will be produced for each byte of input. This value may be used to compute the worst-case size of the output buffer required for a given input sequence.
    2 min read
  • CharsetEncoder unmappableCharacterAction() method in Java with Examples
    The unmappableCharacterAction() method is a built-in method of the java.nio.charset.CharsetEncoder returns this encoder's current action for unmappable-character errors. The CodingErrorAction are of three types IGNORE, REPLACE and REPORT. Syntax: public CodingErrorAction unmappableCharacterAction()
    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