@@ -0,0 +1,2795 @@
+/*%0A * Copyright (C) 2014 Square, Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage okio;%0A%0Aimport java.io.Closeable;%0Aimport java.io.Flushable;%0Aimport java.io.IOException;%0A%0A/**%0A * Receives a stream of bytes. Use this interface to write data wherever it's%0A * needed: to the network, storage, or a buffer in memory. Sinks may be layered%0A * to transform received data, such as to compress, encrypt, throttle, or add%0A * protocol framing.%0A *%0A * %3Cp%3EMost application code shouldn't operate on a sink directly, but rather on a%0A * %7B@link BufferedSink%7D which is both more efficient and more convenient. Use%0A * %7B@link Okio#buffer(Sink)%7D to wrap any sink with a buffer.%0A *%0A * %3Cp%3ESinks are easy to test: just use a %7B@link Buffer%7D in your tests, and%0A * read from it to confirm it received the data that was expected.%0A *%0A * %3Ch3%3EComparison with OutputStream%3C/h3%3E%0A * This interface is functionally equivalent to %7B@link java.io.OutputStream%7D.%0A *%0A * %3Cp%3E%7B@code OutputStream%7D requires multiple layers when emitted data is%0A * heterogeneous: a %7B@code DataOutputStream%7D for primitive values, a %7B@code%0A * BufferedOutputStream%7D for buffering, and %7B@code OutputStreamWriter%7D for%0A * charset encoding. This class uses %7B@code BufferedSink%7D for all of the above.%0A *%0A * %3Cp%3ESink is also easier to layer: there is no %7B@linkplain%0A * java.io.OutputStream#write(int) single-byte write%7D method that is awkward to%0A * implement efficiently.%0A *%0A * %3Ch3%3EInterop with OutputStream%3C/h3%3E%0A * Use %7B@link Okio#sink%7D to adapt an %7B@code OutputStream%7D to a sink. Use %7B@link%0A * BufferedSink#outputStream%7D to adapt a sink to an %7B@code OutputStream%7D.%0A */%0Apublic interface Sink extends Closeable, Flushable %7B%0A  /** Removes %7B@code byteCount%7D bytes from %7B@code source%7D and  them to this. */%0A  // %E4%BB%8Esource%E7%A7%BB%E9%99%A4byteCount%E4%BD%8D%E8%BF%BD%E5%8A%A0%E5%88%B0this%0A  void write(Buffer source, long byteCount) throws IOException;%0A%0A  /** Pushes all buffered bytes to their final destination. */%0A  // flush%0A  @Override void flush() throws IOException;%0A%0A  /** Returns the timeout for this sink. */%0A  Timeout timeout();%0A%0A  /**%0A   * Pushes all buffered bytes to their final destination and releases the%0A   * resources held by this sink. It is an error to write a closed sink. It is%0A   * safe to close a sink more than once.%0A   */%0A  @Override void close() throws IOException;%0A%7D%0A

add Sink.java