Java Charset Create getEncodings()

Here you can find the source of getEncodings()

Description

Returns a list of supported character encodings.

License

Open Source License

Declaration

public static String[] getEncodings() 

Method Source Code

//package com.java2s;
/**//from   w w  w. ja v a2 s. c o m
 * Copyright 2011 The ARIES Consortium (http://www.ariesonline.org) and
 * www.integratedmodelling.org. 
    
   This file is part of Thinklab.
    
   Thinklab is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published
   by the Free Software Foundation, either version 3 of the License,
   or (at your option) any later version.
    
   Thinklab is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.
    
   You should have received a copy of the GNU General Public License
   along with Thinklab.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.nio.charset.Charset;

import java.util.ArrayList;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class Main {
    /**
     * This encoding is not supported by Java, yet it is useful.
     * A UTF-8 file that begins with 0xEFBBBF.
     */
    public static final String UTF_8_Y = "UTF-8Y";

    /**
     * Returns a list of supported character encodings.
     * @since jEdit 4.2pre5
     */
    public static String[] getEncodings() {
        List returnValue = new ArrayList();

        Map map = Charset.availableCharsets();
        Iterator iter = map.keySet().iterator();

        returnValue.add(UTF_8_Y);

        while (iter.hasNext())
            returnValue.add(iter.next());

        return (String[]) returnValue.toArray(new String[returnValue.size()]);
    }
}

Related

  1. getEncoding(OutputStreamWriter inWriter)
  2. getEncoding(String text)
  3. getEncodingOfXml(File file)
  4. getEncodingOption(List options)
  5. getEncodings()