@Override
        public void write(byte[] b, int off, int len) throws IOException {
            if (b == null) {
                throw new NullPointerException();
            } else if ((off < 0) || (off > b.length) || (len < 0) ||
                    ((off + len) > b.length) || ((off + len) < 0)) {
                throw new IndexOutOfBoundsException();
            } else if (len == 0) {
                return;
            }

            if (off == 0 && len == b.length) {
                stream.write(env, new BinaryMemory(b), Memory.NULL);
            } else if (off == 0 && len != b.length) {
                stream.write(env, new BinaryMemory(Arrays.copyOf(b, len)), Memory.NULL);
            } else {
                stream.write(env, new BinaryMemory(Arrays.copyOfRange(b, off, off + len)), Memory.NULL);
            }
        }
@param arg - File path or Stream object
@return
jphp-runtime/src/php/runtime/ext/core/classes/stream/Stream.java