Package java.nio.charset

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


          }
        }
      }
      if (charset != null) {
        try {
          CharBuffer ucs2Chars = charset.decode(ByteBuffer.wrap(crawlData,offset,length));
          return ucs2Chars.toString();
        } catch (Exception e) {
          LOG.error(CCStringUtils.stringifyException(e));
        }
      }
View Full Code Here


            }
           
            Charset contentCharset = Charset.forName(contentEncoding);
            byte[] contentBytes = baos.toByteArray();
            CharBuffer contentChars =
                contentCharset.decode(ByteBuffer.wrap(contentBytes)); // not the most efficient way.
            responseText = contentChars.toString();
            LOG.fine(responseText);
           
            // For a one-way message or whatever, there may not be a content type.
            // throw away any encoding modifier.
View Full Code Here

        // start + length could overflow, start/length maybe MaxInt
        if (start >= 0 && 0 <= length && length <= data.length - start) {
            offset = 0;
            Charset charset = defaultCharset();
            int result;
            CharBuffer cb = charset
                    .decode(ByteBuffer.wrap(data, start, length));
            if ((result = cb.length()) > 0) {
                value = cb.array();
                count = result;
            } else {
View Full Code Here

            Charset charset = getCharset(encoding);

            int result;
          CharBuffer cb;
            try {
              cb = charset.decode(ByteBuffer.wrap(data, start, length));
            } catch (Exception e) {
              // do nothing. according to spec:
              // behavior is unspecified for invalid array
              cb = CharBuffer.wrap("\u003f".toCharArray()); //$NON-NLS-1$
            }
View Full Code Here

        // start + length could overflow, start/length maybe MaxInt
        if (start >= 0 && 0 <= length && length <= data.length - start) {
            offset = 0;
            Charset charset = defaultCharset();
            int result;
            CharBuffer cb = charset
                    .decode(ByteBuffer.wrap(data, start, length));
            if ((result = cb.length()) > 0) {
                value = cb.array();
                count = result;
            } else {
View Full Code Here

            Charset charset = getCharset(encoding);

            int result;
          CharBuffer cb;
            try {
              cb = charset.decode(ByteBuffer.wrap(data, start, length));
            } catch (Exception e) {
              // do nothing. according to spec:
              // behavior is unspecified for invalid array
              cb = CharBuffer.wrap("\u003f".toCharArray()); //$NON-NLS-1$
            }
View Full Code Here

               
                while ((bytesRead = inputStream.read(bytes, offset, 1024)) >= 0) {
                    offset  = bytesRead % 4;
                    chBytes = bytesRead - offset;
                   
                    sb.append(utf32.decode(ByteBuffer.wrap(bytes)).toString());
                   
                    if (offset != 0) {
                        for (int i = 0; i < offset; i += 1) {
                            bytes[i] = bytes[chBytes + i];
                        }
View Full Code Here

            // choose the character set
            String charsetName = getCharsetName(platformID, platformSpecificID);
            Charset charset = Charset.forName(charsetName);
           
            // parse the data as a string
            String value = charset.decode(stringBuf).toString();
       
            // add to the mix
            addRecord(platformID, platformSpecificID, languageID, nameID, value);
        }
    }
View Full Code Here

    buf.put((byte) 0xDF);
    buf.flip();

    final Charset cs = Charset.forName("iso-8859-1");
    assertNotNull(cs);
    final String inputStr = cs.decode(buf).toString();
    log.debug("passing input string: {}", inputStr);
    final String outputStr = echoService.echoString(inputStr);
    assertEquals("unequal strings", inputStr, outputStr);
    log.debug("got output string: {}", outputStr);
View Full Code Here

        baos.write(data, start, data.length - start);
        data = baos.toByteArray();
        if (!charset.equalsIgnoreCase("UTF-8")) {
            ByteBuffer input = ByteBuffer.wrap(data);
            Charset cs = Charset.forName(charset);
            CharBuffer cb = cs.decode(input);
            Charset utf8 = Charset.forName("UTF-8");
            ByteBuffer output = utf8.encode(cb);
            data = output.array();
        }
        return TidyParser.parse(new ByteArrayInputStream(data));
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.