@@ -0,0 +1,3265 @@
+/*%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.IOException;%0A%0A/**%0A * Supplies a stream of bytes. Use this interface to read data from wherever%0A * it's located: from the network, storage, or a buffer in memory. Sources may%0A * be layered to transform supplied data, such as to decompress, decrypt, or%0A * remove protocol framing.%0A *%0A * %3Cp%3EMost applications shouldn't operate on a source directly, but rather on a%0A * %7B@link BufferedSource%7D which is both more efficient and more convenient. Use%0A * %7B@link Okio#buffer(Source)%7D to wrap any source with a buffer.%0A *%0A * %3Cp%3ESources are easy to test: just use a %7B@link Buffer%7D in your tests, and%0A * fill it with the data your application is to read.%0A *%0A * %3Ch3%3EComparison with InputStream%3C/h3%3E%0A * This interface is functionally equivalent to %7B@link java.io.InputStream%7D.%0A *%0A * %3Cp%3E%7B@code InputStream%7D requires multiple layers when consumed data is%0A * heterogeneous: a %7B@code DataInputStream%7D for primitive values, a %7B@code%0A * BufferedInputStream%7D for buffering, and %7B@code InputStreamReader%7D for%0A * strings. This class uses %7B@code BufferedSource%7D for all of the above.%0A *%0A * %3Cp%3ESource avoids the impossible-to-implement %7B@linkplain%0A * java.io.InputStream#available available()%7D method. Instead callers specify%0A * how many bytes they %7B@link BufferedSource#require require%7D.%0A *%0A * %3Cp%3ESource omits the unsafe-to-compose %7B@linkplain java.io.InputStream#mark%0A * mark and reset%7D state that's tracked by %7B@code InputStream%7D; instead, callers%0A * just buffer what they need.%0A *%0A * %3Cp%3EWhen implementing a source, you don't need to worry about the %7B@linkplain%0A * java.io.InputStream#read single-byte read%7D method that is awkward to implement efficiently%0A * and returns one of 257 possible values.%0A *%0A * %3Cp%3EAnd source has a stronger %7B@code skip%7D method: %7B@link BufferedSource#skip%7D%0A * won't return prematurely.%0A *%0A * %3Ch3%3EInterop with InputStream%3C/h3%3E%0A * Use %7B@link Okio#source%7D to adapt an %7B@code InputStream%7D to a source. Use%0A * %7B@link BufferedSource#inputStream%7D to adapt a source to an %7B@code%0A * InputStream%7D.%0A */%0Apublic interface Source extends Closeable %7B%0A  /**%0A   * Removes at least 1, and up to %7B@code byteCount%7D bytes from this and appends%0A   * them to %7B@code sink%7D. Returns the number of bytes read, or -1 if this%0A   * source is exhausted.%0A   * 1-byteCount -%3E sink%0A   */%0A  long read(Buffer sink, long byteCount) throws IOException;%0A%0A  /** Returns the timeout for this source. */%0A  Timeout timeout();%0A%0A  /**%0A   * Closes this source and releases the resources held by this source. It is an%0A   * error to read a closed source. It is safe to close a source more than once.%0A   */%0A  @Override void close() throws IOException;%0A%7D%0A

add Source.java