/** * Returns a {@code char[]} array containing the elements of this stream * which are converted to chars using {@code (char)} cast operation. * * <p> * This is a terminal operation. * * @return an array containing the elements of this stream * @since 0.3.0 */ public char[] toCharArray() { return collectSized(CharBuffer::new, CharBuffer::add, CharBuffer::addAll, CharBuffer::new, CharBuffer::addUnsafe).toArray(); }
/** * Returns a {@code byte[]} array containing the elements of this stream * which are converted to bytes using {@code (byte)} cast operation. * * <p> * This is a terminal operation. * * @return an array containing the elements of this stream * @since 0.3.0 */ public byte[] toByteArray() { return collectSized(ByteBuffer::new, ByteBuffer::add, ByteBuffer::addAll, ByteBuffer::new, ByteBuffer::addUnsafe).toArray(); }
/** * Returns a {@code short[]} array containing the elements of this stream * which are converted to shorts using {@code (short)} cast operation. * * <p> * This is a terminal operation. * * @return an array containing the elements of this stream * @since 0.3.0 */ public short[] toShortArray() { return collectSized(ShortBuffer::new, ShortBuffer::add, ShortBuffer::addAll, ShortBuffer::new, ShortBuffer::addUnsafe).toArray(); }