public final class Okio extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static Sink |
appendingSink(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. |
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.IOExceptionpublic static Source source(InputStream in)
in.public static Source source(File file) throws FileNotFoundException
file.@IgnoreJRERequirement public static Source source(Path path, OpenOption... options) throws IOException
path.IOExceptionpublic static Sink sink(File file) throws FileNotFoundException
file.public static Sink appendingSink(File file) throws FileNotFoundException
file.@IgnoreJRERequirement public static Sink sink(Path path, OpenOption... options) throws IOException
path.IOExceptionpublic static Sink blackhole()
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.IOExceptionCopyright © 2022. All rights reserved.