public ByteArrayInputStream(byte[] buf, int offset, int length) { this.buf = buf; this.pos = offset; this.count = Math.min(offset + length, buf.Length); this._mark = offset; }
public static char[] copyOfRange(char[] original, int from, int to) { int newLength = to - from; if (newLength < 0) { throw new IllegalArgumentException(from + " > " + to); } char[] copy = new char[newLength]; Array.Copy(original, from, copy, 0, Math.min(original.Length - from, newLength)); return(copy); }
public virtual long skip(long n) { long remaining = n; int nr; if (n <= 0) { return(0); } int size = (int)Math.min(MAX_SKIP_BUFFER_SIZE, (int)remaining); byte[] skipBuffer = new byte[size]; while (remaining > 0) { nr = read(skipBuffer, 0, (int)Math.min(size, (int)remaining)); if (nr < 0) { break; } remaining -= nr; } return(n - remaining); }
public static T[] copyOf <T>(T[] original, int newLength) { T[] copy = new T[newLength]; Array.Copy(original, copy, Math.min(original.Length, newLength)); return(copy); }