首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

clojure.java.io

完整名称空间名称:clojure.java.io

概述

代码语言:javascript
复制
This file defines polymorphic I/O utility functions for Clojure.

协议

CoercionsProtocol

代码语言:javascript
复制
Coerce between various 'resource-namish' things.

已知实现:java.io.File、java.lang.String、java.net.URI、java.net.URL、nil

as-filefunction

代码语言:javascript
复制
Usage: (as-file x)
代码语言:javascript
复制
Coerce argument to a file.

在Clojure版本1.2中添加

AS-urlfunction

代码语言:javascript
复制
Usage: (as-url x)
代码语言:javascript
复制
Coerce argument to a URL.

在Clojure版本1.2中添加

IOFactoryProtocol

代码语言:javascript
复制
Factory functions that create ready-to-use, buffered versions of
the various Java I/O stream types, on top of anything that can
be unequivocally converted to the requested kind of stream.

Common options include

  :append    true to open stream in append mode
  :encoding  string name of encoding to use, e.g. "UTF-8".

Callers should generally prefer the higher level API provided by
reader, writer, input-stream, and output-stream.

已知实现:字节数组、字符数组、java.io.BufferedInputStream、java.io.BufferedOutputStream、java.io.BufferedReader、java.io.BufferedWriter、java.io.BufferedWriter、java.io.InputStream、java.io.OutputStream、java.io.Reader、java.io.Writer、java.lang.String、java.nets.ocket、java.net.URI、java.net.URL、nil、Object

输入流函数

代码语言:javascript
复制
Usage: (make-input-stream x opts)
代码语言:javascript
复制
Creates a BufferedInputStream. See also IOFactory docs.

在Clojure版本1.2中添加

输出流函数

代码语言:javascript
复制
Usage: (make-output-stream x opts)
代码语言:javascript
复制
Creates a BufferedOutputStream. See also IOFactory docs.

在Clojure版本1.2中添加

读取器函数

代码语言:javascript
复制
Usage: (make-reader x opts)
代码语言:javascript
复制
Creates a BufferedReader. See also IOFactory docs.

在Clojure版本1.2中添加

造写函数

代码语言:javascript
复制
Usage: (make-writer x opts)
代码语言:javascript
复制
Creates a BufferedWriter. See also IOFactory docs.

在Clojure版本1.2中添加

公共变量和函数

相对路径函数

代码语言:javascript
复制
Usage: (as-relative-path x)
代码语言:javascript
复制
Take an as-file-able thing and return a string if it is
a relative path, else IllegalArgumentException.

在Clojure版本1.2中添加

复制功能

代码语言:javascript
复制
Usage: (copy input output & opts)
代码语言:javascript
复制
Copies input to output.  Returns nil or throws IOException.
Input may be an InputStream, Reader, File, byte[], or String.
Output may be an OutputStream, Writer, or File.

Options are key/value pairs and may be one of

  :buffer-size  buffer size to use, default is 1024.
  :encoding     encoding to use if converting between
                byte and char streams.   

Does not close any streams except those it opens itself 
(on a File).

在Clojure版本1.2中添加

删除-文件功能

代码语言:javascript
复制
Usage: (delete-file f & [silently])
代码语言:javascript
复制
Delete file f. Raise an exception if it fails unless silently is true.

在Clojure版本1.2中添加

文件函数

代码语言:javascript
复制
Usage: (file arg)
       (file parent child)
       (file parent child & more)
代码语言:javascript
复制
Returns a java.io.File, passing each arg to as-file.  Multiple-arg
versions treat the first argument as parent and subsequent args as
children relative to the parent.

在Clojure版本1.2中添加

输入流函数

代码语言:javascript
复制
Usage: (input-stream x & opts)
代码语言:javascript
复制
Attempts to coerce its argument into an open java.io.InputStream.
Default implementations always return a java.io.BufferedInputStream.

Default implementations are defined for InputStream, File, URI, URL,
Socket, byte array, and String arguments.

If the argument is a String, it tries to resolve it first as a URI, then
as a local file name.  URIs with a 'file' protocol are converted to
local file names.

Should be used inside with-open to ensure the InputStream is properly
closed.

在Clojure版本1.2中添加

使父母功能

代码语言:javascript
复制
Usage: (make-parents f & more)
代码语言:javascript
复制
Given the same arg(s) as for file, creates all parent directories of
the file they represent.

在Clojure版本1.2中添加

输出流函数

代码语言:javascript
复制
Usage: (output-stream x & opts)
代码语言:javascript
复制
Attempts to coerce its argument into an open java.io.OutputStream.
Default implementations always return a java.io.BufferedOutputStream.

Default implementations are defined for OutputStream, File, URI, URL,
Socket, and String arguments.

If the argument is a String, it tries to resolve it first as a URI, then
as a local file name.  URIs with a 'file' protocol are converted to
local file names.

Should be used inside with-open to ensure the OutputStream is
properly closed.

在Clojure版本1.2中添加

读函数

代码语言:javascript
复制
Usage: (reader x & opts)
代码语言:javascript
复制
Attempts to coerce its argument into an open java.io.Reader.
Default implementations always return a java.io.BufferedReader.

Default implementations are provided for Reader, BufferedReader,
InputStream, File, URI, URL, Socket, byte arrays, character arrays,
and String.

If argument is a String, it tries to resolve it first as a URI, then
as a local file name.  URIs with a 'file' protocol are converted to
local file names.

Should be used inside with-open to ensure the Reader is properly
closed.

在Clojure版本1.2中添加

资源函数

代码语言:javascript
复制
Usage: (resource n)
       (resource n loader)
代码语言:javascript
复制
Returns the URL for a named resource. Use the context class loader
if no loader is specified.

在Clojure版本1.2中添加

写函数

代码语言:javascript
复制
Usage: (writer x & opts)
代码语言:javascript
复制
Attempts to coerce its argument into an open java.io.Writer.
Default implementations always return a java.io.BufferedWriter.

Default implementations are provided for Writer, BufferedWriter,
OutputStream, File, URI, URL, Socket, and String.

If the argument is a String, it tries to resolve it first as a URI, then
as a local file name.  URIs with a 'file' protocol are converted to
local file names.

Should be used inside with-open to ensure the Writer is properly
closed.

在Clojure版本1.2中添加

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com