Java File Read by Charset getFileEncodingCharset()

Here you can find the source of getFileEncodingCharset()

Description

Returns the Charset which is equal to the "file.encoding" property.

License

GNU General Public License

Declaration

public static Charset getFileEncodingCharset() 

Method Source Code

//package com.java2s;
/* This code is part of Freenet. It is distributed under the GNU General
 * Public License, version 2 (or at your option any later version). See
 * http://www.gnu.org/ for further details of the GPL. */

import java.nio.charset.Charset;

public class Main {
    /**//from   ww  w. java  2 s. co m
     * Returns the Charset which is equal to the "file.encoding" property.
     * This property is set to the users configured system language on windows for example.
     *
     * If any error occurs, the default Charset is returned. Therefore this function should never throw.
     */
    public static Charset getFileEncodingCharset() {
        try {
            return Charset.forName(System.getProperty("file.encoding"));
        } catch (Throwable t) {
            return Charset.defaultCharset();
        }
    }
}

Related

  1. fixture(String filename, Charset charset)
  2. getContent(File file, String charsetName)
  3. getEOL(File file, Charset charset)
  4. getFileContent(File file, String charsetName)
  5. getFileContents(File file, String charset)
  6. getFileText(File file, Charset charset)
  7. getNumberOfNonEmptyLines(File file, Charset charset)
  8. getPatchFileCharset()
  9. getPropertiesVaule(File file, String key, Charset charset)