public final class Okio
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) static java.util.logging.Logger |
logger |
Modifier | Constructor and Description |
---|---|
private |
Okio() |
Modifier and Type | Method and Description |
---|---|
static Sink |
appendingSink(java.io.File file)
Returns a sink that appends to
file . |
static Sink |
blackhole()
Returns a sink that writes nowhere.
|
static BufferedSink |
buffer(Sink sink)
Returns a new sink that buffers writes to
sink . |
static BufferedSource |
buffer(Source source)
Returns a new source that buffers reads from
source . |
(package private) static boolean |
isAndroidGetsocknameError(java.lang.AssertionError e)
Returns true if
e is due to a firmware bug fixed after Android 4.2.2. |
static Sink |
sink(java.io.File file)
Returns a sink that writes to
file . |
static Sink |
sink(java.io.OutputStream out)
Returns a sink that writes to
out . |
private static Sink |
sink(java.io.OutputStream out,
Timeout timeout) |
static Sink |
sink(java.nio.file.Path path,
java.nio.file.OpenOption... options)
Returns a sink that writes to
path . |
static Sink |
sink(java.net.Socket socket)
Returns a sink that writes to
socket . |
static Source |
source(java.io.File file)
Returns a source that reads from
file . |
static Source |
source(java.io.InputStream in)
Returns a source that reads from
in . |
private static Source |
source(java.io.InputStream in,
Timeout timeout) |
static Source |
source(java.nio.file.Path path,
java.nio.file.OpenOption... options)
Returns a source that reads from
path . |
static Source |
source(java.net.Socket socket)
Returns a source that reads from
socket . |
private static AsyncTimeout |
timeout(java.net.Socket socket) |
public static BufferedSource buffer(Source source)
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.public static BufferedSink buffer(Sink sink)
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.public static Sink sink(java.io.OutputStream out)
out
.public static Sink sink(java.net.Socket socket) throws java.io.IOException
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.java.io.IOException
public static Source source(java.io.InputStream in)
in
.public static Source source(java.io.File file) throws java.io.FileNotFoundException
file
.java.io.FileNotFoundException
public static Source source(java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.IOException
path
.java.io.IOException
public static Sink sink(java.io.File file) throws java.io.FileNotFoundException
file
.java.io.FileNotFoundException
public static Sink appendingSink(java.io.File file) throws java.io.FileNotFoundException
file
.java.io.FileNotFoundException
public static Sink sink(java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.IOException
path
.java.io.IOException
public static Sink blackhole()
public static Source source(java.net.Socket socket) throws java.io.IOException
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.java.io.IOException
private static AsyncTimeout timeout(java.net.Socket socket)
static boolean isAndroidGetsocknameError(java.lang.AssertionError e)
e
is due to a firmware bug fixed after Android 4.2.2.
https://code.google.com/p/android/issues/detail?id=54072