Package java.io

Examples of java.io.UnsupportedEncodingException


     */
    public static String codepageToEncoding(final int codepage)
    throws UnsupportedEncodingException
    {
        if (codepage <= 0)
            throw new UnsupportedEncodingException
                ("Codepage number may not be " + codepage);
        switch (codepage)
        {
            case Constants.CP_UTF16:
                return "UTF-16";
View Full Code Here


        Message message = mailMessage.getMessage();
        try {
            return message.getContent();
        } catch (Exception e) {
            // try to fix message in case it has an unsupported encoding in the Content-Type header
            UnsupportedEncodingException uee = ObjectHelper.getException(UnsupportedEncodingException.class, e);
            if (uee != null) {
                LOG.debug("Unsupported encoding detected: " + uee.getMessage());
                try {
                    String contentType = message.getContentType();
                    String type = ObjectHelper.before(contentType, "charset=");
                    if (type != null) {
                        // try again with fixed content type
View Full Code Here

     */
    public static String codepageToEncoding(final int codepage)
    throws UnsupportedEncodingException
    {
        if (codepage <= 0)
            throw new UnsupportedEncodingException
                ("Codepage number may not be " + codepage);
        switch (codepage)
        {
            case Constants.CP_UTF16:
                return "UTF-16";
View Full Code Here

    StringBuilder sb = new StringBuilder(numChars > 500 ? numChars / 2 : numChars);
    int i = 0;

    if (enc.length() == 0)
    {
      throw new RuntimeException(new UnsupportedEncodingException(
        "URLDecoder: empty string enc parameter"));
    }

    char c;
    byte[] bytes = null;
View Full Code Here

        int encoding = prescanXMLDeclOrTextDecl(declReader, xmlDecl);
        if (encoding == -1) {
            data.rewind();
            // REVISIT - The document is not well-formed.  There is no encoding, yet the file is
            //   clearly not UTF8.
            throw new UnsupportedEncodingException(null);
        }
        String enc = stringPool.orphanString(encoding).toUpperCase();
        if ("ISO-10646-UCS-2".equals(enc)) throw new UnsupportedEncodingException(enc);
        if ("ISO-10646-UCS-4".equals(enc)) throw new UnsupportedEncodingException(enc);
        if ("UTF-16".equals(enc)) throw new UnsupportedEncodingException(enc);
        String javaencname = MIME2Java.convert(enc);
        if (null == javaencname) {
            if (allowJavaEncodingName) {
                javaencname = enc;
            } else {
                throw new UnsupportedEncodingException(enc);
            }
        }
        try {
            data.rewind();
            reader = readerFactory.createCharReader(entityHandler, errorReporter, sendCharDataAsCharArray, new InputStreamReader(data, javaencname), stringPool);
View Full Code Here

                        XMLEntityHandler.EntityReader declReader = new XMLDeclReader(entityHandler, errorReporter, sendCharDataAsCharArray, data, stringPool);
                        int encoding = prescanXMLDeclOrTextDecl(declReader, xmlDecl);
                        if (encoding != -1) {
                            String encname = stringPool.orphanString(encoding);
                            String enc = encname.toUpperCase();
                            if ("ISO-10646-UCS-2".equals(enc)) throw new UnsupportedEncodingException(encname);
                            if ("ISO-10646-UCS-4".equals(enc)) throw new UnsupportedEncodingException(encname);
                            if ("UTF-16".equals(enc)) throw new UnsupportedEncodingException(encname);

                            String javaencname = MIME2Java.convert(enc);
                            if (null == javaencname) {
                                // Not supported
                                if (allowJavaEncodingName) {
                                    javaencname = encname;
                                } else {
                                    throw new UnsupportedEncodingException(encname);
                                }
                            }
                            try {
                                data.rewind();
                                if ("UTF-8".equalsIgnoreCase(javaencname) || "UTF8".equalsIgnoreCase(javaencname)) {
                                    reader = readerFactory.createUTF8Reader(entityHandler, errorReporter, sendCharDataAsCharArray, data, stringPool);
                                } else {
                                    reader = readerFactory.createCharReader(entityHandler, errorReporter, sendCharDataAsCharArray,
                                                                            new InputStreamReader(data, javaencname), stringPool);
                                }
                            } catch (UnsupportedEncodingException e) {
                                throw new UnsupportedEncodingException(encname);
                            } catch (Exception e) {
                                if( debug == true )
                                   e.printStackTrace();            // Internal Error
                            }
                        } else {
View Full Code Here

        return 14;
      case 'f':
      case 'F':
        return 15;
    }
    throw new UnsupportedEncodingException();
  }
View Full Code Here

        return 14;
      case 'f':
      case 'F':
        return 15;
    }
    throw new UnsupportedEncodingException();
  }
View Full Code Here

            if (Charset.isSupported(csn)) {
                return Charset.forName(csn);
            }
        } catch (IllegalCharsetNameException x) {}

        throw new UnsupportedEncodingException(csn);
    }
View Full Code Here

                return Charset.forName(csn);
            }
        } catch (IllegalCharsetNameException x) {
        }

        throw JDBCUtil.sqlException(new UnsupportedEncodingException(csn));
    }
View Full Code Here

TOP

Related Classes of java.io.UnsupportedEncodingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.