Truncates the stream to the specified length.

        @param size: The length of the stream, in bytes.
        @type size: C{int}
775614
def truncate(self, size=0):
        
        if size == 0:
            self._buffer = StringIO()
            self._len_changed = True

            return

        cur_pos = self.tell()
        self.seek(0)
        buf = self.read(size)
        self._buffer = StringIO()

        self._buffer.write(buf)
        self.seek(cur_pos)
        self._len_changed = True
726198
def resize(self, size=None):
        

        if not self.operation.israw():
            return

        size = size or tty.size(self.operation.stdout)

        if size is not None:
            rows, cols = size
            try:
                self.operation.resize(height=rows, width=cols)
            except IOError:  # Container already exited
                pass
348670
def truncate(self, n):
        """"""
        # Current byte position - (n * data_size)
        size = self.size - n * self.__strct.size

        # Erase [size] bytes from file.tell()
        self.__file.truncate(size)
137719
private void setLimit(int from, int size) {
		request.setFrom(from);

		if (size > -1) {
			request.setSize(size);
		}
	}
379406
public function truncate($size)
    {
        if($this->isWritable())
        {
            if($this->getType() == 'memory')
            {
                if ($this->_length > $size) {
                    $this->_resource = substr($this->_resource, 0, $size);
                } else {
                    $this->_resource = str_pad($this->_resource, $size, "\0", STR_PAD_RIGHT);
                }
            }
            else return parent::truncate($size);

            return true;
        }

        return false;
    }
425627
@Override
    public void setBufferSize(int size) {
        if (this.writing || isClosed()) {
            throw new IllegalStateException("Stream unable to set size");
        }
        this.amountToBuffer = size;
        this.bbSize = (49152 < size) ? 32768 : 8192;

        // make sure we never create larger frames than the max http2 frame size
        Integer h2size = (Integer) this.getVc().getStateMap().get("h2_frame_size");
        if (h2size != null && h2size < bbSize) {
            this.bbSize = h2size;
        }

        int numBuffers = (size / this.bbSize);
        if (0 == size || 0 != (size % this.bbSize)) {
            numBuffers++;
        }
        this.output = new WsByteBuffer[numBuffers];
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "setBufferSize=" + size + "; " + this);
        }
    }
308663
def _truncate_wrapper(self):
        
        io_attr = getattr(self._io, 'truncate')

        def truncate_wrapper(*args, **kwargs):
            """Wrap truncate call to call flush after truncate."""
            if self._append:
                self._io.seek(self._read_seek, self._read_whence)
            size = io_attr(*args, **kwargs)
            self.flush()
            if not self.is_stream:
                self.file_object.size = size
                buffer_size = len(self._io.getvalue())
                if buffer_size < size:
                    self._io.seek(buffer_size)
                    self._io.write('\0' * (size - buffer_size))
                    self.file_object.set_contents(
                        self._io.getvalue(), self._encoding)
                    self._flush_pos = size
                    if self._filesystem.is_macos or sys.version_info[0] > 2:
                        self._adapt_size_for_related_files(size - buffer_size)

            self.flush()
            if not IS_PY2:
                return size

        return truncate_wrapper
994939
public void skipRawBytes(final int size) throws IOException {
    if (size < 0) {
      throw ProtobufException.negativeSize();
    }

    if (totalBytesRetired + bufferPos + size > currentLimit) {
      // Read to the end of the stream anyway.
      skipRawBytes(currentLimit - totalBytesRetired - bufferPos);
      // Then fail.
      throw ProtobufException.truncatedMessage();
    }

    if (size <= bufferSize - bufferPos) {
      // We have all the bytes we need already.
      bufferPos += size;
    } else {
      // Skipping more bytes than are in the buffer.  First skip what we have.
      int pos = bufferSize - bufferPos;
      bufferPos = bufferSize;

      // Keep refilling the buffer until we get to the point we wanted to skip
      // to.  This has the side effect of ensuring the limits are updated
      // correctly.
      refillBuffer(true);
      while (size - pos > bufferSize) {
        pos += bufferSize;
        bufferPos = bufferSize;
        refillBuffer(true);
      }

      bufferPos = size - pos; 
    }
  }
796040
public void trimToSize() {
		if (_size < _data.length) {
			_data = _size == 0
				? EMPTY_ARRAY
				: copyOf(_data, _size);
		}
	}
619725
public Cell<C,T> size (float size) {
		size(new FixedValue<C, T>(layout.toolkit, size));
		return this;
	}
569461
public EvictionConfigurationBuilder size(long size) {
      attributes.attribute(SIZE).set(size);
      memory().size(size);
      memory().storageType(StorageType.OBJECT);
      return this;
   }
337528
public function truncate(int $size): bool
    {
        $this->size = $size;
        foreach (array_filter(array_keys($this->content),
                              function($pos) use ($size)
                              {
                                  return $pos >= $size;
                              }
                ) as $removePos) {
            unset($this->content[$removePos]);
        }

        return true;
    }
75878
public void clear(int size, int off) {
    if (size%4 != 4) size = (size/4+1)*4;
    next = null;
    previous = null;
    data = new byte[size];
    offset = off;
    for(int i = 0; i < data.length; i++)
      data[i] = 0;
    usableBits = off;
  }
1288119
public function stream_truncate(int $size): bool
    {
        if (self::READONLY === $this->mode) {
            return false;
        }

        if ($this->content->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
            return false;
        }

        if ($this->content->getType() !== vfsStreamContent::TYPE_FILE) {
            return false;
        }

        if (self::$quota->isLimited() && $this->content->size() < $size) {
            $maxSize = self::$quota->spaceLeft(self::$root->sizeSummarized());
            if (0 === $maxSize) {
                return false;
            }

            if ($size > $maxSize) {
                $size = $maxSize;
            }
        }

        return $this->content->truncate($size);
    }
867690
def truncate(self, max_length):
        """"""

        if self.length() > max_length:

            # If it's longer than the max_length, scale to the max_length.
            self.scale(max_length / self.length())
1246331
public T textSize(float size) {

        if (view instanceof TextView) {
            TextView tv = (TextView) view;
            tv.setTextSize(size);
        }
        return self();
    }
1357722
public WrappedByteBuffer skip(int size) {
        _autoExpand(size);
        _buf.position(_buf.position() + size);
        return this;
    }