Package java.nio.charset

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


            //}

            // The following appears to be necessary to ensure that encoding errors are not recovered.
            Charset charset = Charset.forName(encoding);
            CharsetDecoder decoder = charset.newDecoder();
            decoder = decoder.onMalformedInput(CodingErrorAction.REPORT);
            decoder = decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
            return new BufferedReader(new InputStreamReader(is, decoder));


        } catch (IOException err) {
View Full Code Here


        Map attrs = null;
        String stringValue = value.getString();
        boolean isXMLSafe = true;
        if (value.isBinary()) {
            CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder();
            decoder.onMalformedInput(CodingErrorAction.REPORT);
            decoder.onMalformedInput(CodingErrorAction.REPORT);
            try {
                stringValue = decoder.decode(ByteBuffer.wrap(value.getBytes())).toString();
            } catch (CharacterCodingException e) {
                isXMLSafe = false;
View Full Code Here

        String stringValue = value.getString();
        boolean isXMLSafe = true;
        if (value.isBinary()) {
            CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder();
            decoder.onMalformedInput(CodingErrorAction.REPORT);
            decoder.onMalformedInput(CodingErrorAction.REPORT);
            try {
                stringValue = decoder.decode(ByteBuffer.wrap(value.getBytes())).toString();
            } catch (CharacterCodingException e) {
                isXMLSafe = false;
            }
View Full Code Here

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

        return decoder;
    }
View Full Code Here

        Map<Charset, CharsetDecoder> map = decoders.get();
        CharsetDecoder d = map.get(charset);
        if (d != null) {
            d.reset();
            d.onMalformedInput(CodingErrorAction.REPLACE);
            d.onUnmappableCharacter(CodingErrorAction.REPLACE);
            return d;
        }

        d = charset.newDecoder();
View Full Code Here

            d.onUnmappableCharacter(CodingErrorAction.REPLACE);
            return d;
        }

        d = charset.newDecoder();
        d.onMalformedInput(CodingErrorAction.REPLACE);
        d.onUnmappableCharacter(CodingErrorAction.REPLACE);
        map.put(charset, d);
        return d;
    }
View Full Code Here

  }

  private static String decode(final ByteBuffer b, final Charset charset)
      throws CharacterCodingException {
    final CharsetDecoder d = charset.newDecoder();
    d.onMalformedInput(CodingErrorAction.REPORT);
    d.onUnmappableCharacter(CodingErrorAction.REPORT);
    return d.decode(b).toString();
  }

  /**
 
View Full Code Here

    /**
     * @return a new {@link CharsetDecoder} instance for this server.
     */
    public CharsetDecoder newDecoder() {
        CharsetDecoder decoder = this.encoding.newDecoder();
        decoder.onMalformedInput(this.errorAction);
        decoder.onUnmappableCharacter(this.errorAction);
        return decoder;
    }

    /**
 
View Full Code Here

    /**
     * @return a new {@link CharsetDecoder} instance for this server.
     */
    public CharsetDecoder newDecoder() {
        CharsetDecoder decoder = this.encoding.newDecoder();
        decoder.onMalformedInput(this.errorAction);
        decoder.onUnmappableCharacter(this.errorAction);
        return decoder;
    }

    /**
 
View Full Code Here

        CharsetDecoder dec = Chars.getDecoder();
        // Blocking finite Pool - does not happen.
        // Plain Pool (sync wrapped) - might - allocate an extra one.
        if ( dec == null )
            dec = Chars.createDecoder() ;
        dec
          .onMalformedInput(CodingErrorAction.REPLACE)
          .onUnmappableCharacter(CodingErrorAction.REPLACE)
          .reset() ;
       
        return dec ;
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.