Java Charset Create getEncoding(OutputStreamWriter inWriter)

Here you can find the source of getEncoding(OutputStreamWriter inWriter)

Description

Get the default system encoding using a writer

License

Open Source License

Parameter

Parameter Description
inWriter writer object

Return

string defining encoding

Declaration

public static String getEncoding(OutputStreamWriter inWriter) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.OutputStreamWriter;
import java.nio.charset.Charset;

public class Main {
    /**/*from   ww w .  ja  v  a2s  .  co  m*/
     * Get the default system encoding using a writer
     * @param inWriter writer object
     * @return string defining encoding
     */
    public static String getEncoding(OutputStreamWriter inWriter) {
        String encoding = inWriter.getEncoding();
        try {
            encoding = Charset.forName(encoding).name();
        } catch (Exception e) {
        } // ignore failure to find encoding
        return encoding;
    }
}

Related

  1. getEncoder()
  2. getEncoder()
  3. getEncoder()
  4. getEncoder(String encoding)
  5. getEncoding(byte[] htmlData)
  6. getEncoding(String text)
  7. getEncodingOfXml(File file)
  8. getEncodingOption(List options)
  9. getEncodings()