public final class Okio extends Object
Modifier and Type | Method and Description |
---|---|
static Sink |
appendingSink(File file)
Returns a sink that appends to
file . |
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 . |
static Sink |
sink(File file)
Returns a sink that writes to
file . |
static Sink |
sink(OutputStream out)
Returns a sink that writes to
out . |
static Sink |
sink(Path path,
OpenOption... options)
Returns a sink that writes to
path . |
static Sink |
sink(Socket socket)
Returns a sink that writes to
socket . |
static Source |
source(File file)
Returns a source that reads from
file . |
static Source |
source(InputStream in)
Returns a source that reads from
in . |
static Source |
source(Path path,
OpenOption... options)
Returns a source that reads from
path . |
static Source |
source(Socket socket)
Returns a source that reads from
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(OutputStream out)
out
.public static Sink sink(Socket socket) throws 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.IOException
public static Source source(InputStream in)
in
.public static Source source(File file) throws FileNotFoundException
file
.FileNotFoundException
public static Source source(Path path, OpenOption... options) throws IOException
path
.IOException
public static Sink sink(File file) throws FileNotFoundException
file
.FileNotFoundException
public static Sink appendingSink(File file) throws FileNotFoundException
file
.FileNotFoundException
public static Sink sink(Path path, OpenOption... options) throws IOException
path
.IOException
public static Source source(Socket socket) throws 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.IOException
Copyright © 2017. All rights reserved.