Package java.nio

Examples of java.nio.CharBuffer.flip()


            }
        }
        catch (CharacterCodingException x) {
            throw new IllegalStateException(x);
        }
        return dst.flip().toString();
    }

    /**
     * Returns a cached thread-local {@link java.nio.charset.CharsetDecoder} for the specified <tt>charset</tt>.
     */
 
View Full Code Here


        ByteBuffer inBuf = ByteBuffer.wrap(in);
        CharBuffer outBuf = CharBuffer.allocate(inBuf.capacity()*Math.round(decoder.maxCharsPerByte() + 0.5f));
        decoder.decode(inBuf, outBuf, true);
        decoder.flush(outBuf);
        decoder.reset();
        return outBuf.flip().toString();
    }

    private static String getCurrentUser() throws SVNException {
        if (isWindows || isOpenVMS) {
            return System.getProperty("user.name");
View Full Code Here

                cr.throwException();
            }
        } catch (CharacterCodingException x) {
            throw new IllegalStateException(x);
        }
        return dst.flip().toString();
    }

    private ChannelBuffers() {
        // Unused
    }
View Full Code Here

    while (true) {
      final int n = input.read(buffer);
      if (n == -1) {
        break;
      }
      buffer.flip();
      text.append(buffer, 0, n);
    }
    return text;
  }
View Full Code Here

    while (true) {
      final int n = input.read(buffer);
      if (n == -1) {
        break;
      }
      buffer.flip();
      text.append(buffer, 0, n);
    }
    return text;
  }
View Full Code Here

            dec.reset();
            CoderResult cr = dec.decode(bb, cb, true);
            assert cr.isUnderflow();
            cr = dec.flush(cb);
            assert cr.isUnderflow();
            sb.append(cb.flip().toString());
        }

        return sb.toString();
    }
View Full Code Here

     *          If an encoding operation is already in progress
     */
    public boolean canEncode(char c) {
        CharBuffer cb = CharBuffer.allocate(1);
        cb.put(c);
        cb.flip();
        return canEncode(cb);
    }

    /**
     * Tells whether or not this encoder can encode the given character
View Full Code Here

                cb.put ( (char) sl );
            } else {
                cb.put ( (char) cc );
            }
        }
        cb.flip();
        return (CharSequence) cb;
    }

}
View Full Code Here

  public void testAppendCharSequenceNormal() throws IOException {
    CharBuffer cb = CharBuffer.allocate(10);
    cb.put('A');
    assertSame(cb, cb.append("String"));
    assertEquals("AString", cb.flip().toString());
    cb.append(null);
    assertEquals("null", cb.flip().toString());
  }

  public void testAppendCharSequenceIINormal() throws IOException {
View Full Code Here

    CharBuffer cb = CharBuffer.allocate(10);
    cb.put('A');
    assertSame(cb, cb.append("String"));
    assertEquals("AString", cb.flip().toString());
    cb.append(null);
    assertEquals("null", cb.flip().toString());
  }

  public void testAppendCharSequenceIINormal() throws IOException {
    CharBuffer cb = CharBuffer.allocate(10);
    cb.put('A');
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.