Output is created with new Output(new ByteArrayOutputStream())
This will automatically resize internally
328256
public static KryoPool withByteArrayOutputStream(int poolSize,
      final KryoInstantiator ki) {
    return new KryoPool(poolSize) {
      protected SerDeState newInstance() {
        return new SerDeState(ki.newKryo(), new Input(), new Output(new ByteArrayOutputStream())) {
          /*
           * We have to take extra care of the ByteArrayOutputStream
           */
          @Override
          public void clear() {
            super.clear();
            ByteArrayOutputStream byteStream = (ByteArrayOutputStream)output.getOutputStream();
            byteStream.reset();
          }
          @Override
          public byte[] outputToBytes() {
            output.flush();
            ByteArrayOutputStream byteStream = (ByteArrayOutputStream)output.getOutputStream();
            return byteStream.toByteArray();
          }
          @Override
          public void writeOutputTo(OutputStream os) throws IOException {
            output.flush();
            ByteArrayOutputStream byteStream = (ByteArrayOutputStream)output.getOutputStream();
            byteStream.writeTo(os);
          }
        };
      }
    };
  }
673521
public static void writeArrayToOutputStream(INDArray arr, OutputStream outputStream) {
        ByteBuffer buffer = BinarySerde.toByteBuffer(arr);
        try (WritableByteChannel channel = Channels.newChannel(outputStream)) {
            channel.write(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
812106
@Override
    public void writeExternal(ObjectOutput output) throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(tc, "Serializing: " + this);
        }
        super.writeExternal(output);
        // write out the byte[] to avoid hardcoding impl information (ordinals)
        writeByteArray(output, getMethodValue().getByteArray());
        writeByteArray(output, getSchemeValue().getByteArray());

        writeByteArray(output, getRequestURIAsByteArray());
        writeByteArray(output, getQueryStringAsByteArray());
    }
702292
@Override
    public void dump(OutputStream output) {
        try (PrintWriter out = new PrintWriter(new OutputStreamWriter(output, UTF_8))) {
            for (long value : values) {
                out.printf("%d%n", value);
            }
        }
    }
735642
public static long copy(
                    final InputStream input,
                    final File output
                    )
    throws IOException
    {
        OutputStream  stream_output = null;
        long  size = 0L;
        try {
            stream_output = new FileOutputStream( output );
                            //throws FileNotFoundException
            size = copy( input, stream_output );
                   //throws IOException
        } finally {
            try {
                stream_output.close();
            } catch (Exception ex) {
                //ignorable
            }
        }

        return size;

    }
915986
private static void copyStream(InputStream is, OutputStream os, int bufferSize)
            throws IOException {
        Assert.checkNotNullParam("is", is);
        Assert.checkNotNullParam("os", os);
        byte[] buff = new byte[bufferSize];
        int rc;
        while ((rc = is.read(buff)) != -1) os.write(buff, 0, rc);
        os.flush();
    }
920157
public void dumpOriginal(PrintStream out) {
        out.println("seq\tversion\ttime\tclasses\tNCSS\tadded\tnewCode\tfixed\tremoved\tretained\tdead\tactive");
        for (int i = 0; i < versionList.length; ++i) {
            Version version = versionList[i];
            AppVersion appVersion = sequenceToAppVersionMap.get(version.getSequence());
            out.print(i);
            out.print('\t');
            out.print(appVersion != null ? appVersion.getReleaseName() : "");
            out.print('\t');
            if (formatDates) {
                out.print("\"" + (appVersion != null ? dateFormat.format(new Date(appVersion.getTimestamp())) : "") + "\"");
            } else {
                out.print(appVersion != null ? appVersion.getTimestamp() / 1000 : 0L);
            }
            out.print('\t');
            if (appVersion != null) {
                out.print(appVersion.getNumClasses());
                out.print('\t');
                out.print(appVersion.getCodeSize());

            } else {
                out.print("\t0\t0");
            }

            for (int j = 0; j < TUPLE_SIZE; ++j) {
                out.print('\t');
                out.print(version.get(j));
            }
            out.println();
        }
    }
1131747
private void makeNewFile() throws IOException {
		String filename=prefix+(files.size()+1)+suffix;
		File file=new File(parent, filename);
		out=new FileOutputStream(file);
		bytesOut=0;
		files.add(file);
	}
254756
public static long copyAndCloseOutput(InputStream input, OutputStream output) throws IOException {
		try (OutputStream outputStream = output) {
			return copy(input, outputStream);
		}
	}
1273505
public static void copy(final InputStream in, final OutputStream out)
			throws IOException {
		copy(in, out, DEFAULT_BUFFER_SIZE);
	}
1029402
public void setOutput(OutputStream os, String encoding) throws IOException {
		if (os == null)
			throw new IllegalArgumentException("output stream can not be null");
		reset();
		if (encoding != null) {
			out = new OutputStreamWriter(os, encoding);
		} else {
			out = new OutputStreamWriter(os);
		}
	}
859571
@Override
    public void encode(OutputStream output, Indenter indenter, String nsURI) {

        // Make a PrintStream for a nicer printing interface
        PrintStream out = new PrintStream(output);

        // Prepare the indentation string
        char[] topIndent = indenter.makeString().toCharArray();
        out.print(topIndent);
        if (nsURI != null) {
            out.append("<Request xmlns=\"").append(nsURI).println("\">");
        } else {
            out.println("<Request>");
        }
        // go in one more for next-level elements...
        indenter.in();
        char[] indent = indenter.makeString().toCharArray();

        // ...and go in again for everything else
        indenter.in();

        // first off, go through all subjects
        Iterator it = subjects.iterator();
        while (it.hasNext()) {
            Subject subject = (Subject)(it.next());
            encodeSubject(subject, out, indenter);
        }

        // next do the resource
        if ((resource.size() != 0) || (resourceContent != null)) {
            out.print(indent);
            out.println("<Resource>");
            if (resourceContent != null)
                out.append(indenter.makeString()).append("<ResourceContent>")
                   .append(resourceContent).println("</ResourceContent>");
            encodeAttributes(resource, out, indenter);
            out.print(indent);
            out.println("</Resource>");
        } else {
            out.print(indent);
            out.println("<Resource/>");
        }

        // now the action
        if (action.size() != 0) {
            out.print(indent);
            out.println("<Action>");
            encodeAttributes(action, out, indenter);
            out.print(indent);
            out.println("</Action>");
        } else {
            out.print(indent);
            out.println("<Action/>");
        }


        //Bug ID:1745062 
        out.print(indent);
        out.println("<Environment>");
        // finally the environment, if there are any attrs
        if (environment.size() != 0) {
            encodeAttributes(environment, out, indenter);
        } 
        out.print(indent);
        out.println("</Environment>");

        // we're back to the top
        indenter.out();
        indenter.out();
        
        out.print(topIndent);
        out.println("</Request>");
    }
1175489
public static void copyBytes(final InputStream in, final OutputStream out) throws IOException {
		copyBytes(in, out, BLOCKSIZE, true);
	}
584235
protected OutputStream createOutputStream (File target)
        throws IOException
    {
        // make sure the parent directory exists
        target.getParentFile().mkdirs();
        // now create our file
        JarOutputStream jout = new JarOutputStream(new FileOutputStream(target));
        jout.setLevel(uncompressed() ? Deflater.NO_COMPRESSION : Deflater.BEST_COMPRESSION);
        return jout;
    }
25403
public static void copyStream(InputStream is, OutputStream os, int bufferSize)
            throws IOException {
        if (is == null) {
            throw MESSAGES.nullArgument("input stream");
        }
        if (os == null) {
            throw MESSAGES.nullArgument("output stream");
        }
        byte[] buff = new byte[bufferSize];
        int rc;
        while ((rc = is.read(buff)) != -1) { os.write(buff, 0, rc); }
        os.flush();
    }
1313059
@Override
    public ServletOutputStream getOutputStream() throws IOException {

        if(_out == null ){
            //create the outputstream 
            _out = new SRTUpgradeOutputStream31();       
            _outbb = new UpgradeOutputByteBufferUtil(this);
            _out.init(_outbb,_req);
        }
        return _out;
    }
818406
private void resizeIfNeeded()
    {
        // resize the window if we need to
        int oldRenderWidth = Display.getWidth(); 
        int oldRenderHeight = Display.getHeight();
        if( this.renderWidth == oldRenderWidth && this.renderHeight == oldRenderHeight )
            return;
        
        try {
            int old_x = Display.getX();
            int old_y = Display.getY();
            Display.setLocation(old_x, old_y);
            Display.setDisplayMode(new DisplayMode(this.renderWidth, this.renderHeight));
            System.out.println("Resized the window");
        } catch (LWJGLException e) {
            System.out.println("Failed to resize the window!");
            e.printStackTrace();
        }
        forceResize(this.renderWidth, this.renderHeight);
    }