Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
I'm doing some work using the JavaMail API, and I've run across encodings which Java doesn't support natively (by design), such as UTF7/unicode-1-1-utf-7. For that encoding in particular I found the JUTF7 implementation of a Java Charset and CharsetProvider for UTF7. However, having added the jutf7.jar to my classpath I still get UnsupportedEncodingExceptions, and unicode-1-1-utf-7 is definitel...
I have to make changes to an old project which uses J2SE 1.4. Now as I run the project I get the error javax.servlet.ServletException: The character set 'IBM437' is supported by the JSE 1.1 API, but not the J2SE 1.4 API. This requires fixing the Java Runtime Environment! Please read the Javadoc of this error class for more information. at org.apache.jasper.runtime.PageContextImpl.handlePa...
I'm using a legacy binary message format that requires a character sequence in ASCII-6 (6 bit ascii) encoding. I couldn't find a definition for ASCII-6 but they define the character mappings in their spec starting with A=0x01, B=0x02, etc. I'm wondering if there is an existing characterset in java for ASCII-6. If not can you create or define your own characterset somehow? If not is there a bet...
in Taiwan we have a character encoding called "Unicode At One (UAO)", which is an extension to BIG-5 but is not supported by Java and Android. The code page is in http://moztw.org/docs/big5/table/uao241-b2u.txt My question is, how can I build a String object with byte array data, using this Charset? I guess I will extend the String class and do something in it, but I have no idea how to crea...
  /*
   * Copyright 2000-2004 Sun Microsystems, Inc.  All Rights Reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Sun designates this
   * particular file as subject to the "Classpath" exception as provided
   * by Sun in the LICENSE file that accompanied this code.
  *
  * This code 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
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  * CA 95054 USA or visit www.sun.com if you need additional information or
  * have any questions.
  */
 
 package java.nio.charset.spi;
 
Charset service-provider class.

A charset provider is a concrete subclass of this class that has a zero-argument constructor and some number of associated charset implementation classes. Charset providers may be installed in an instance of the Java platform as extensions, that is, jar files placed into any of the usual extension directories. Providers may also be made available by adding them to the applet or application class path or by some other platform-specific means. Charset providers are looked up via the current thread's context class loader.

A charset provider identifies itself with a provider-configuration file named java.nio.charset.spi.CharsetProvider in the resource directory META-INF/services. The file should contain a list of fully-qualified concrete charset-provider class names, one per line. A line is terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a line feed. Space and tab characters surrounding each name, as well as blank lines, are ignored. The comment character is '#' ('\u0023'); on each line all characters following the first comment character are ignored. The file must be encoded in UTF-8.

If a particular concrete charset provider class is named in more than one configuration file, or is named in the same configuration file more than once, then the duplicates will be ignored. The configuration file naming a particular provider need not be in the same jar file or other distribution unit as the provider itself. The provider must be accessible from the same class loader that was initially queried to locate the configuration file; this is not necessarily the class loader that loaded the file.

Author(s):
Mark Reinhold
JSR-51 Expert Group
Since:
1.4
See also:
java.nio.charset.Charset
 
 
 public abstract class CharsetProvider {

    
Initializes a new charset provider.

Throws:
java.lang.SecurityException If a security manager has been installed and it denies java.lang.RuntimePermission("charsetProvider")
 
     protected CharsetProvider() {
         SecurityManager sm = System.getSecurityManager();
         if (sm != null)
             sm.checkPermission(new RuntimePermission("charsetProvider"));
     }

    
Creates an iterator that iterates over the charsets supported by this provider. This method is used in the implementation of the java.nio.charset.Charset.availableCharsets() method.

Returns:
The new iterator
 
     public abstract Iterator<Charsetcharsets();

    
Retrieves a charset for the given charset name.

Parameters:
charsetName The name of the requested charset; may be either a canonical name or an alias
Returns:
A charset object for the named charset, or null if the named charset is not supported by this provider
    public abstract Charset charsetForName(String charsetName);
New to GrepCode? Check out our FAQ X