Package java.io

Examples of java.io.UnsupportedEncodingException


        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) {
                                e.printStackTrace();            // Internal Error
                            }
                        } else {
                            data.rewind();
View Full Code Here

        // accepts "null" because it indicates using default encoding
        if (null == newEncoding) {
            this.encoding = null;
        } else {
            // logging.13=The encoding "{0}" is not supported.
            throw new UnsupportedEncodingException("The encoding \"" + newEncoding + "\" is not supported.");
        }
    }
View Full Code Here

    @Test
    public void urlUnsupportedEncodingTest() {
        Request request = new Request(Command.GetSystemHypothetical) {
            @Override
            protected String encode(Object value) throws UnsupportedEncodingException {
                throw new UnsupportedEncodingException("Martian OS does not support UTF-8");
            }
        };
        request.put(Parameter.Systems, new DotString<String>("1234.321"));
        request.put(Parameter.Password, "PA55");
        request.put(Parameter.EMail, "me@here.com");
View Full Code Here

        if (normalizedEncoding == null) {
            String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG", LOG, new Object[] {
                enc
            }).toString();
            LOG.log(Level.WARNING, m);
            throw new UnsupportedEncodingException(m);
        }

        return normalizedEncoding;
    }
View Full Code Here

    {
      charset = Charset.forName(charsetName);
    }
    catch (IllegalCharsetNameException e)
    {
      throw new RuntimeException(new UnsupportedEncodingException(charsetName));
    }
    catch (UnsupportedCharsetException e)
    {
      throw new RuntimeException(new UnsupportedEncodingException(charsetName));
    }

    boolean stopEncoding = false;
    for (int i = 0; i < s.length();)
    {
View Full Code Here

        if (normalizedEncoding == null) {
            String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG", LOG, new Object[] {
                enc
            }).toString();
            LOG.log(Level.WARNING, m);
            throw new UnsupportedEncodingException(m);
        }

        return normalizedEncoding;
    }
View Full Code Here

            throw new NullPointerException();
        }

        // If the given encoding is an empty string throw an exception.
        if (enc.length() == 0) {
            throw new UnsupportedEncodingException(
                    // K00a5=Invalid parameter - {0}
                    Msg.getString("K00a5", "enc")); //$NON-NLS-1$ //$NON-NLS-2$
        }

        if (s.indexOf('%') == -1) {
            if (s.indexOf('+') == -1)
                return s;
            char str[] = s.toCharArray();
            for (int i = 0; i < str.length; i++) {
                if (str[i] == '+')
                    str[i] = ' ';
            }
            return new String(str);
        }

        Charset charset = null;
        try {
            charset = Charset.forName(enc);
        } catch (IllegalCharsetNameException e) {
            throw (UnsupportedEncodingException) (new UnsupportedEncodingException(
                    enc).initCause(e));
        } catch (UnsupportedCharsetException e) {
            throw (UnsupportedEncodingException) (new UnsupportedEncodingException(
                    enc).initCause(e));
        }

        return decode(s, charset);
    }
View Full Code Here

        Charset charset = lastCharset;
        if (charset == null || !encoding.equalsIgnoreCase(charset.name())) {
            try {
                charset = Charset.forName(encoding);
            } catch (IllegalCharsetNameException e) {
                throw (UnsupportedEncodingException) (new UnsupportedEncodingException(
                        encoding).initCause(e));
            } catch (UnsupportedCharsetException e) {
                throw (UnsupportedEncodingException) (new UnsupportedEncodingException(
                        encoding).initCause(e));
            }
            lastCharset = charset;
        }
        return charset;
View Full Code Here

                Charset cs = lookupCharset(csn);
                if (cs != null)
                    sd = new StringDecoder(cs, csn);
            } catch (IllegalCharsetNameException x) {}
            if (sd == null)
                throw new UnsupportedEncodingException(csn);
            set(decoder, sd);
        }
        return sd.decode(ba, off, len);
    }
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.