Package java.nio.charset

Examples of java.nio.charset.CharsetDecoder.replaceWith()


                        // start after the NUL
                        if (cc.cbopt.charAt(1) == 0x00) {
                            cc.cbopt = cc.cbopt.substring(2);

                            try {
                                decoder.replaceWith(cc.cbopt);
                            } catch (Exception e) {
                                logln("Skipping test due to limitation in Java API - substitution character sequence size error");
                            }
                        }
                    }
View Full Code Here


        CharsetDecoder decoder = charset.newDecoder();
       
        decoder.onUnmappableCharacter(actions.onUnmappableCharacter);
        decoder.onMalformedInput(actions.onMalformedInput);
       
        if (actions.replaceWith != null) decoder.replaceWith(actions.replaceWith.toString());

        return decoder;
    }

    private CharsetEncoder getCharsetEncoder(Charset charset) {
View Full Code Here

   
    static String inputStreamToString(InputStream is) throws IOException {
        CharsetDecoder decoder = Charsets.US_ASCII.newDecoder();
        decoder.onMalformedInput(CodingErrorAction.IGNORE);
        decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
        decoder.replaceWith("?");
        CharBuffer buffer = decoder.decode(
            ByteBuffer.wrap(StreamUtil.inputStream2Bytes(is)));
        String t = buffer.toString();
        t = (t.length()<(MAX_BODY_CHARS+1))? t: t.substring(MAX_BODY_CHARS);
        if(t.isEmpty()) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.