Package java.nio.charset

Examples of java.nio.charset.Charset


        super(resourceObject, cacheable, versioned);
    }

    @Override
    public InputStream getInputStream() throws IOException {
        Charset charset = ResourceUtils.getCharsetFromContentType(getContentType());
        FacesContextWrapperImpl wrappedContext = FacesContextWrapperImpl.wrap(charset);
        try {
            encode(wrappedContext);

            return wrappedContext.getWrittenDataAsStream();
View Full Code Here


        return Executors.newFixedThreadPool(poolSize);
    }

    private Collection<ResourceProcessor> getDefaultResourceProcessors() {

        Charset charset = Charset.defaultCharset();
        if (!Strings.isNullOrEmpty(encoding)) {
            charset = Charset.forName(encoding);
        } else {
            log.warn(
                    "Encoding is not set explicitly, CDK resources plugin will use default platform encoding for processing char-based resources");
View Full Code Here

        super(baseUrl);
    }

    @Override
    public HttpURLConnection openConnectionInternal() throws IOException {
        Charset utf8 = Charset.forName("UTF-8");
        byte[] data = getParameterString().getBytes(utf8);
        HttpURLConnection conn = (HttpURLConnection) getBaseUrl().openConnection();
        conn.setUseCaches(shouldUseCaches());
        conn.setInstanceFollowRedirects(shouldFollowRedirects());
        conn.setDoOutput(true);
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        conn.setRequestProperty("charset", utf8.toString());
        conn.setRequestProperty("Content-Length", Integer.toString(data.length));
        new DataOutputStream(conn.getOutputStream()).write(data);
        return conn;
    }
View Full Code Here

    @Override
    public void execute(InputStream in, GraphPropertyWorkData data) throws Exception {
        String mimeType = (String) data.getProperty().getMetadata().get(LumifyProperties.MIME_TYPE.getPropertyName());
        checkNotNull(mimeType, LumifyProperties.MIME_TYPE.getPropertyName() + " is a required metadata field");

        Charset charset = Charset.forName("UTF-8");
        Metadata metadata = new Metadata();
        metadata.set(Metadata.CONTENT_TYPE, mimeType);
        String text = extractText(in, mimeType, metadata);

        ExistingElementMutation<Vertex> m = data.getElement().prepareMutation();
View Full Code Here

            return;
        }
        if (lineEnding == null) {
            lineEnding = LINE_SEPARATOR;
        }
        final Charset cs = Charsets.toCharset(encoding);
        for (final Object line : lines) {
            if (line != null) {
                output.write(line.toString().getBytes(cs));
            }
            output.write(lineEnding.getBytes(cs));
View Full Code Here

            return h.getEncoding();
        }

        try {

            Charset cs = Charset.forName(name);
            return new NioZipEncoding(cs);

        } catch (UnsupportedCharsetException e) {
            return new FallbackZipEncoding(name);
        }
View Full Code Here

     *
     * @param env
     */
    private void logMessage(SMTPSession session, MailEnvelopeImpl env)
    {
    Charset charset = Charset.forName("US-ASCII");

    try {
      InputStream in = env.getMessageInputStream();
      byte[] buf = new byte[16384];
      CharsetDecoder decoder = charset.newDecoder();
      int len = 0;
      while ((len = in.read(buf)) >= 0) {
        session.getLogger().trace(decoder.decode(ByteBuffer.wrap(buf, 0, len)).toString());
      }
    } catch (IOException ioex) {
View Full Code Here

        return getBytes(intBits);
    }

    public static byte[] getBytes(String data, String charsetName)
    {
        Charset charset = Charset.forName(charsetName);
        return data.getBytes(charset);
    }
View Full Code Here

        }

        final StringBuilder sb = new StringBuilder((int) fc.size());
        // TODO: Make sure that the entire world settles on one encoding and
        // that every file in existance is re-encoded.
        final Charset cs = Charset.forName("UTF-8");
        while (fc.read(buf) != -1) {
            buf.rewind();
            final CharBuffer chbuf = cs.decode(buf);
            sb.append(chbuf.array());
            buf.clear();
        }

        in.close();
View Full Code Here

   * @throws UnsupportedCharsetException if the character encoding is not supported or recognised.
   */
  public URIDecodingFilter(final TokenStream input, final String charsetEncoding)
  throws UnsupportedCharsetException {
    super(input);
    final Charset charset = this.lookupCharset(charsetEncoding);
    charsetDecoder = charset.newDecoder()
                            .onMalformedInput(CodingErrorAction.REPLACE)
                            .onUnmappableCharacter(CodingErrorAction.REPLACE);
    termAtt = this.addAttribute(CharTermAttribute.class);
    posIncrAtt = this.addAttribute(PositionIncrementAttribute.class);
    termBuffer = CharBuffer.allocate(256);
View Full Code Here

TOP

Related Classes of java.nio.charset.Charset

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.