Package java.nio.charset

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


      bytes[i] = (byte) in;
    }

    // decode byte data to characters
    ByteBuffer bb = ByteBuffer.wrap(bytes);
    CharBuffer cb = csets.decode(bb);

    // compare these characters to the pattern String
    for(int i = 0; i < pattern.length(); i++)
      if(cb.charAt(i) != pattern.charAt(i))
        return false;
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 (i < len && data[i] != '\'') i++;
        i++;
      } while (i < len && data[i] != ','); // word must end with "',"
     
      if (i >= len) break; // EOF
      String word = charset.decode(ByteBuffer.wrap(data, start, i-start-1)).toString();
//      String word = new String(data, 0, start, i-start-1); // ASCII
     
      /*
       * Part B: ignore phrases (with spaces and hyphens) and
       * non-alphabetic words, and let user customize word (e.g. do some
View Full Code Here

             * XML parse.
             */
            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);
           
            if (responseBytes.length > 0
                && ("text/xml".equals(contentType)
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

    *
    * @return this returns the bytes sequence as a string object
    */  
   private String encode(String encoding, ByteBuffer buffer) throws IOException {
      Charset charset = Charset.forName(encoding);
      CharBuffer text = charset.decode(buffer);

      return text.toString();
   }

   /**
 
View Full Code Here

    *
    * @return this returns the bytes sequence as a string object
    */
   private String encode(String encoding, ByteBuffer segment) throws IOException {
      Charset charset = Charset.forName(encoding);
      CharBuffer text = charset.decode(segment);

      return text.toString();
   }

   /**
 
View Full Code Here

       Charset charSet = getCharset();
      
       byte[] crcBytes = Arrays.copyOfRange(bytes, 0, 4);
       byte[] textBytes = Arrays.copyOfRange(bytes, 4, bytes.length);
      
       CharBuffer crcChar = charSet.decode(ByteBuffer.wrap(crcBytes));
       CharBuffer textChar = charSet.decode(ByteBuffer.wrap(textBytes));
      
       // Get crc of text to see if same
       String cryptCRC = crcChar.toString();
       String realCRC = crcHeader(textBytes);
View Full Code Here

      
       byte[] crcBytes = Arrays.copyOfRange(bytes, 0, 4);
       byte[] textBytes = Arrays.copyOfRange(bytes, 4, bytes.length);
      
       CharBuffer crcChar = charSet.decode(ByteBuffer.wrap(crcBytes));
       CharBuffer textChar = charSet.decode(ByteBuffer.wrap(textBytes));
      
       // Get crc of text to see if same
       String cryptCRC = crcChar.toString();
       String realCRC = crcHeader(textBytes);
      
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.