Package okio
Class Okio
- java.lang.Object
-
- okio.Okio
-
public final class Okio extends java.lang.ObjectEssential APIs for working with Okio.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SinkappendingSink(java.io.File file)Returns a sink that appends tofile.static Sinkblackhole()Returns a sink that writes nowhere.static BufferedSinkbuffer(Sink sink)Returns a new sink that buffers writes tosink.static BufferedSourcebuffer(Source source)Returns a new source that buffers reads fromsource.static Sinksink(java.io.File file)Returns a sink that writes tofile.static Sinksink(java.io.OutputStream out)Returns a sink that writes toout.static Sinksink(java.net.Socket socket)Returns a sink that writes tosocket.static Sinksink(java.nio.file.Path path, java.nio.file.OpenOption... options)Returns a sink that writes topath.static Sourcesource(java.io.File file)Returns a source that reads fromfile.static Sourcesource(java.io.InputStream in)Returns a source that reads fromin.static Sourcesource(java.net.Socket socket)Returns a source that reads fromsocket.static Sourcesource(java.nio.file.Path path, java.nio.file.OpenOption... options)Returns a source that reads frompath.
-
-
-
Method Detail
-
buffer
public static BufferedSource buffer(Source source)
Returns a new source that buffers reads fromsource. 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 tosink. The returned sink will batch writes tosink. Use this wherever you write to a sink to get an ergonomic and efficient access to data.
-
sink
public static Sink sink(java.io.OutputStream out)
Returns a sink that writes toout.
-
sink
public static Sink sink(java.net.Socket socket) throws java.io.IOException
Returns a sink that writes tosocket. Prefer this oversink(OutputStream)because this method honors timeouts. When the socket write times out, the socket is asynchronously closed by a watchdog thread.- Throws:
java.io.IOException
-
source
public static Source source(java.io.InputStream in)
Returns a source that reads fromin.
-
source
public static Source source(java.io.File file) throws java.io.FileNotFoundException
Returns a source that reads fromfile.- Throws:
java.io.FileNotFoundException
-
source
@IgnoreJRERequirement public static Source source(java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.IOException
Returns a source that reads frompath.- Throws:
java.io.IOException
-
sink
public static Sink sink(java.io.File file) throws java.io.FileNotFoundException
Returns a sink that writes tofile.- Throws:
java.io.FileNotFoundException
-
appendingSink
public static Sink appendingSink(java.io.File file) throws java.io.FileNotFoundException
Returns a sink that appends tofile.- Throws:
java.io.FileNotFoundException
-
sink
@IgnoreJRERequirement public static Sink sink(java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.IOException
Returns a sink that writes topath.- Throws:
java.io.IOException
-
blackhole
public static Sink blackhole()
Returns a sink that writes nowhere.
-
source
public static Source source(java.net.Socket socket) throws java.io.IOException
Returns a source that reads fromsocket. Prefer this oversource(InputStream)because this method honors timeouts. When the socket read times out, the socket is asynchronously closed by a watchdog thread.- Throws:
java.io.IOException
-
-