Package java.nio.charset

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


                    break;
                }
            }

            // Reset for next decode
            decoder.reset();
            pendingByteBuffer.position(0);
        }

        pendingByteCount = 0;
    }
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;
        }
View Full Code Here

        if (charset == null) {
            throw new IllegalArgumentException("Charset can not be null");
        }
       
        final CharsetDecoder decoder = obtainCodecsCache().getDecoder(charset);
        decoder.reset();
       
        return decoder;
    }
   
    /**
 
View Full Code Here

        }
        CharBuffer result = CharBuffer.allocate(n);
        if (n == 0)
            return result;

        decoder.reset();
        while (true) {
            CoderResult cr = buffer.hasRemaining() ? decoder.decode(buffer,
                    result, true) : decoder.flush(result);
            if (cr.isUnderflow())
                break;
View Full Code Here

      Matcher matcher = encodedCharsMulti.matcher(path);
      StringBuffer buf = new StringBuffer();
      CharsetDecoder decoder = Charset.forName(UTF_8).newDecoder();
      while (matcher.find())
      {
         decoder.reset();
         String decoded = decodeBytes(matcher.group(1), decoder);
         decoded = decoded.replace("\\", "\\\\");
         decoded = decoded.replace("$", "\\$");
         matcher.appendReplacement(buf, decoded);
      }
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;
        }
View Full Code Here

   
    public static String decode(ByteBuffer bb, Charset cs, CharBuffer cb)  {
      CharsetDecoder de = ThreadLocalCoders.decoderFor(cs)
          .onMalformedInput(CodingErrorAction.REPLACE)
        .onUnmappableCharacter(CodingErrorAction.REPLACE);
      de.reset();
      int len = bb.remaining();
      CoderResult rt = de.decode(bb, cb, true);
      if (rt == CoderResult.OVERFLOW) {
        cb.flip();
        CharBuffer lcb = CharBuffer.allocate((int)(len * (double)de.maxCharsPerByte()));
 
View Full Code Here

                        do {
                            byteBuffer.position(0);
                            byteBuffer.limit(currentLength);
                           
                            try {
                                charBuffer = decoder.reset().decode(byteBuffer);
                            }
                            catch ( MalformedInputException e ) {
                                // this exception we expect to get if when we slice the byte buffer to
                                // the intended byte length, we end up mid-way through a byte sequence.
                                currentLength--;
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;
        }
View Full Code Here

                if (c != '%')
                    break;
            }
            bb.flip();
            cb.clear();
            dec.reset();
            CoderResult cr = dec.decode(bb, cb, true);
            if (cr.isError())
                throw new IllegalArgumentException("Error decoding percent encoded characters");
            cr = dec.flush(cb);
            if (cr.isError())
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.