Package java.nio

Examples of java.nio.CharBuffer.position()


          if (endOfInput) {
            if (encodingBuffer.hasRemaining()) {
              result = CoderResult
                  .malformedForLength(encodingBuffer
                      .remaining());
              encodingBuffer.position(encodingBuffer.limit());
            }
          } else {
            if (encodingBuffer.hasRemaining()) {
              remains = new char[encodingBuffer.remaining()];
              encodingBuffer.get(remains);
View Full Code Here


        // otherwise, the decode process ends.
        break;
      }
    }
    // set in new position
    int offset = encodingBuffer.position() > remainsLength ? (encodingBuffer
        .position() - remainsLength)
        : 0;
    in.position(inOldPosition + offset);

    status = endOfInput ? END : ONGOING;
View Full Code Here

        // otherwise, the decode process ends.
        break;
      }
    }
    // set in new position
    int offset = encodingBuffer.position() > remainsLength ? (encodingBuffer
        .position() - remainsLength)
        : 0;
    in.position(inOldPosition + offset);

    status = endOfInput ? END : ONGOING;
View Full Code Here

            boolean needInput = !bytes.hasRemaining();

            while (out.hasRemaining()) {
                // fill the buffer if needed
                if (needInput) {
                    if ((in.available() == 0) && (out.position() > offset)) {
                        // we could return the result without blocking read
                        break;
                    }

                    int to_read = bytes.capacity() - bytes.limit();
View Full Code Here

                throw new MalformedInputException(result.length());
            } else if (result.isUnmappable()) {
                throw new UnmappableCharacterException(result.length());
            }

            return out.position() - offset == 0 ? -1 : out.position() - offset;
        }
    }

    /*
     * Answer a boolean indicating whether or not this InputStreamReader is
View Full Code Here

                throw new MalformedInputException(result.length());
            } else if (result.isUnmappable()) {
                throw new UnmappableCharacterException(result.length());
            }

            return out.position() - offset == 0 ? -1 : out.position() - offset;
        }
    }

    /*
     * Answer a boolean indicating whether or not this InputStreamReader is
View Full Code Here

    {
        // I think that the copy from some mutable collector to immutable string is inevitable in java. 
        int len = bb.remaining() ;
        CharBuffer cb = CharBuffer.allocate(len) ;
        toChars(bb, cb) ;
        return new String(cb.array(), 0, cb.position()) ;
    }

    // Using buffer access.
    private static void toCharsBuffer(ByteBuffer bb, CharBuffer cb)
    {
View Full Code Here

            } catch (CharacterCodingException x) {
                // Substitution is always enabled,
                // so this shouldn't happen
                throw new Error(x);
            }
            return safeTrim(ca, cb.position(), cs, isTrusted);
        }
    }

    static char[] decode(byte[] ba, int off, int len) {
        String csn = Charset.defaultCharset().name();
View Full Code Here

                } catch (CharacterCodingException x) {
                    // Substitution is always enabled,
                    // so this shouldn't happen
                    throw new Error(x);
                }
                return safeTrim(ca, cb.position(), cs, isTrusted);
            }
        }
    }

    static char[] decode(String charsetName, byte[] ba, int off, int len)
View Full Code Here

      } catch (CharacterCodingException x) {
        // Substitution is always enabled,
        // so this shouldn't happen
        throw new Error(x);
      }
      return safeTrim(ca, cb.position(), cs);
    }

  }

  /**
 
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.