API for io - clojure-contrib v1.2 (stable)

by Stuart Sierra

clojure-contrib is now deprecated

clojure-contrib is no longer being developed or maintained.

Rather than a single, monolithic, contributions library, Clojure now has a set of separate libraries for each unit of functionality. The libraries are in the Clojure GitHub organization at https://github.com/clojure. API documentation of the libraries can be found at https://clojure.github.io.

If you're looking for a specific function or namespace from the old clojure-contrib, see "Where Did Clojure.Contrib Go".


Full namespace name: clojure.contrib.io

Overview

This file defines polymorphic I/O utility functions for Clojure.

The Streams protocol defines reader, writer, input-stream and
output-stream methods that return BufferedReader, BufferedWriter,
BufferedInputStream and BufferedOutputStream instances (respectively),
with default implementations extended to a variety of argument
types: URLs or filenames as strings, java.io.File's, Sockets, etc.

Public Variables and Functions



*append*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
If true, writer, output-stream and spit will open files in append mode.
Defaults to false.  Instead of binding this var directly, use append-writer,
append-output-stream or append-spit.
Source


*buffer-size*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Size, in bytes or characters, of the buffer used when
copying streams.
Source


*byte-array-type*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Type object for a Java primitive byte array.
Source


*char-array-type*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Type object for a Java primitive char array.
Source


*default-encoding*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Name of the default encoding to use when reading & writing.
Default is UTF-8.
Source


append-output-stream

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (append-output-stream x)
Like output-stream but opens file for appending.  Does not work on streams
that are already open.
Deprecated since clojure-contrib version 1.2
Source


append-spit

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (append-spit f content)
Like spit but appends to file.
Deprecated since clojure-contrib version 1.2
Source


append-writer

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (append-writer x)
Like writer but opens file for appending.  Does not work on streams
that are already open.
Deprecated since clojure-contrib version 1.2
Source


as-url

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (as-url arg)
Coerces argument (URL, URI, or String) to a java.net.URL.
Deprecated since clojure-contrib version 1.2
Source


copy

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (copy input output)
Copies input to output.  Returns nil.
Input may be an InputStream, Reader, File, byte[], or String.
Output may be an OutputStream, Writer, or File.

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

Writing a File fails if the parent directory does not exist.
Deprecated since clojure-contrib version 1.2
Source


delete-file

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (delete-file f & [silently])
Delete file f. Raise an exception if it fails unless silently is true.
Source


delete-file-recursively

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (delete-file-recursively f & [silently])
Delete file f. If it's a directory, recursively delete all its contents.
Raise an exception if any deletion fails unless silently is true.
Source


file

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (file arg)
       (file parent child)
       (file parent child & more)
Returns a java.io.File from string or file args.
Deprecated since clojure-contrib version 1.2
Source


file-str

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (file-str & args)
Concatenates args as strings and returns a java.io.File.  Replaces
all / and \ with File/separatorChar.  Replaces ~ at the start of
the path with the user.home system property.
Source


input-stream

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (input-stream x)
Attempts to coerce its argument into an open java.io.InputStream.
The default implementations of this protocol always return a
java.io.BufferedInputStream.

Default implementations are defined for OutputStream, 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.


make-parents

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (make-parents file)
Creates all parent directories of file.
Source


output-stream

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (output-stream x)
Attempts to coerce its argument into an open java.io.OutputStream.
The default implementations of this protocol 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.


pwd

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (pwd)
Returns current working directory as a String.  (Like UNIX 'pwd'.)
Note: In Java, you cannot change the current working directory.
Deprecated since clojure-contrib version 1.2
Source


read-lines

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (read-lines f)
Like clojure.core/line-seq but opens f with reader.  Automatically
closes the reader AFTER YOU CONSUME THE ENTIRE SEQUENCE.
Source


reader

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (reader x)
Attempts to coerce its argument into an open java.io.Reader.
The default implementations of this protocol 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.  If this fails, a final attempt is made to resolve
the string as a resource on the CLASSPATH.

Uses *default-encoding* as the text encoding.

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


relative-path-string

multimethod
This library, clojure-contrib, is deprecated. See here for more information.
No usage documentation available
Interpret a String or java.io.File as a relative path string.
Building block for clojure.contrib.java/file.
Deprecated since clojure-contrib version 1.2
Source


slurp*

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (slurp* f)
Like clojure.core/slurp but opens f with reader.
Deprecated since clojure-contrib version 1.2
Source


spit

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (spit f content)
Opposite of slurp.  Opens f with writer, writes content, then
closes f.
Deprecated since clojure-contrib version 1.2
Source


to-byte-array

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (to-byte-array arg)
Converts argument into a Java byte array.  Argument may be
a String, File, InputStream, or Reader.  If the argument is already
a byte array, returns it.
Source


with-in-reader

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (with-in-reader f & body)
Opens a PushbackReader on f, binds it to *in*, and evaluates body.
Source


with-out-append-writer

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (with-out-append-writer f & body)
Like with-out-writer but appends to file.
Deprecated since clojure-contrib version 1.2
Source


with-out-writer

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (with-out-writer f & body)
Opens a writer on f, binds it to *out*, and evalutes body.
Anything printed within body will be written to f.
Source


write-lines

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (write-lines f lines)
Writes lines (a seq) to f, separated by newlines.  f is opened with
writer, and automatically closed at the end of the sequence.
Source


writer

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (writer x)
Attempts to coerce its argument into an open java.io.Writer.
The default implementations of this protocol 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.
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.