final OutputStream output = response.getOutputStream(); byte[] data = ... output.write(data);
public static void writeChunked(final byte[] data, final OutputStream output) throws IOException { if (data != null) { int bytes = data.length; int offset = 0; while (bytes > 0) { int chunk = Math.min(bytes, DEFAULT_BUFFER_SIZE); output.write(data, offset, chunk); bytes -= chunk; offset += chunk; } } }
想獲取最新內容,請關注微信公衆號
微信