Package okio

Class Okio

java.lang.Object
okio.Okio

public final class Okio extends Object
Essential APIs for working with Okio.
  • Method Details

    • buffer

      public static BufferedSource buffer(Source source)
      Returns a new source that buffers reads from source. The returned source will perform bulk reads into its in-memory buffer. Use this wherever you read a source to get an ergonomic and efficient access to data.
    • buffer

      public static BufferedSink buffer(Sink sink)
      Returns a new sink that buffers writes to sink. The returned sink will batch writes to sink. Use this wherever you write to a sink to get an ergonomic and efficient access to data.
    • sink

      public static Sink sink(OutputStream out)
      Returns a sink that writes to out.
    • sink

      public static Sink sink(Socket socket) throws IOException
      Returns a sink that writes to socket. Prefer this over sink(OutputStream) because this method honors timeouts. When the socket write times out, the socket is asynchronously closed by a watchdog thread.
      Throws:
      IOException
    • source

      public static Source source(InputStream in)
      Returns a source that reads from in.
    • source

      public static Source source(File file) throws FileNotFoundException
      Returns a source that reads from file.
      Throws:
      FileNotFoundException
    • source

      @IgnoreJRERequirement public static Source source(Path path, OpenOption... options) throws IOException
      Returns a source that reads from path.
      Throws:
      IOException
    • sink

      public static Sink sink(File file) throws FileNotFoundException
      Returns a sink that writes to file.
      Throws:
      FileNotFoundException
    • appendingSink

      public static Sink appendingSink(File file) throws FileNotFoundException
      Returns a sink that appends to file.
      Throws:
      FileNotFoundException
    • sink

      @IgnoreJRERequirement public static Sink sink(Path path, OpenOption... options) throws IOException
      Returns a sink that writes to path.
      Throws:
      IOException
    • blackhole

      public static Sink blackhole()
      Returns a sink that writes nowhere.
    • source

      public static Source source(Socket socket) throws IOException
      Returns a source that reads from socket. Prefer this over source(InputStream) because this method honors timeouts. When the socket read times out, the socket is asynchronously closed by a watchdog thread.
      Throws:
      IOException