Package java.nio.charset

Examples of java.nio.charset.Charset.newEncoder()


                cconfig.getUnmappableInputAction() : CodingErrorAction.REPORT;
        if (charset != null) {
            chardecoder = charset.newDecoder();
            chardecoder.onMalformedInput(malformedInputAction);
            chardecoder.onUnmappableCharacter(unmappableInputAction);
            charencoder = charset.newEncoder();
            charencoder.onMalformedInput(malformedInputAction);
            charencoder.onUnmappableCharacter(unmappableInputAction);
        }
        final String id = "http-outgoing-" + Long.toString(COUNTER.getAndIncrement());
        return new LoggingManagedHttpClientConnection(
View Full Code Here


     */
    private boolean hasProperDefaultCharset()
    {
        final String charSetName = System.getProperty("file.encoding");
        final Charset charSet = Charset.forName(charSetName);
        return charSet.newEncoder().canEncode('\u00e4');
    }



    /**
 
View Full Code Here

     */
    private boolean hasProperDefaultCharset()
    {
        final String charSetName = System.getProperty("file.encoding");
        final Charset charSet = Charset.forName(charSetName);
        return charSet.newEncoder().canEncode('\u00e4');
    }
}
View Full Code Here

  {
    this.encoding = encoding;
    this.encodingvalid = true;
   
    final Charset charset = Charset.forName(encoding);
    this.charsetEncoder = charset.newEncoder();
  }

  /**
   * Writes an opening XML tag that has no attributes.
   *
 
View Full Code Here

    protected final void setEncoding(final String encoding)
    throws UnsupportedEncodingException {

        final Charset charSet = charsetForName(encoding);
        final CharsetEncoder encoder = charSet.newEncoder().onMalformedInput(
            CodingErrorAction.REPLACE).onUnmappableCharacter(
            CodingErrorAction.REPLACE);
        final float maxBytesPerChar     = encoder.maxBytesPerChar();
        final float averageBytesPerChar = encoder.averageBytesPerChar();
        final boolean fixedWidthCharset =
View Full Code Here

  public void init(JMMarshallerImpl pController) throws JAXBException {
    super.init(pController);
    Charset charSet = Charset.forName(pController.getEncoding());
    if (charSet.canEncode()) {
      charsetEncoder = charSet.newEncoder();
    }
  }

  public boolean canEncode(char c) {
    return (charsetEncoder == null) ? false : charsetEncoder.canEncode(c);
View Full Code Here

  @Test
  public void strings() {
    String ss = "仰望着天空寻找一位失去的故友悄无声息的离开了也带上了命运";
    Charset UTF8 = Charset.forName("UTF-8");
    CharsetEncoder enc = UTF8.newEncoder();
    // enc.

  }

  @Test
View Full Code Here

        String message= NLSUtility.format(TextEditorMessages.DocumentProvider_error_illegal_encoding_message_arg, encoding);
        IStatus s= new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, IStatus.OK, message, ex);
        throw new CoreException(s);
      }

      CharsetEncoder encoder= charset.newEncoder();
      encoder.onMalformedInput(CodingErrorAction.REPLACE);
      encoder.onUnmappableCharacter(CodingErrorAction.REPORT);

      InputStream stream;
View Full Code Here

            }
            return b;
        }
        try {
            Charset cc = Charset.forName(encoding);
            CharsetEncoder ce = cc.newEncoder();
            ce.onUnmappableCharacter(CodingErrorAction.IGNORE);
            CharBuffer cb = CharBuffer.wrap(text.toCharArray());
            java.nio.ByteBuffer bb = ce.encode(cb);
            bb.rewind();
            int lim = bb.limit();
View Full Code Here

            b[3] = (byte)(char1 & 0xff);
            return b;
        }
        try {
            Charset cc = Charset.forName(encoding);
            CharsetEncoder ce = cc.newEncoder();
            ce.onUnmappableCharacter(CodingErrorAction.IGNORE);
            CharBuffer cb = CharBuffer.wrap(new char[]{char1});
            java.nio.ByteBuffer bb = ce.encode(cb);
            bb.rewind();
            int lim = bb.limit();
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.