tupelo.io

Read/Write using DataInputStream/DataOutputStream & InputStream/OutputStream

->File

(->File arg)
Inputs: [arg :- (s/cond-pre s/Str File Path)]
Returns: File

Convert a String or Path arg to a File. Idempotent.

->Path

(->Path arg)
Inputs: [arg :- (s/cond-pre s/Str File Path)]
Returns: Path

Convert a String or File arg to a Path. Idempotent.

create-temp-directory

(create-temp-directory prefix)(create-temp-directory dir prefix)
Inputs: ([prefix :- (s/cond-pre File s/Str Path)] [dir :- (s/cond-pre File s/Str Path) prefix :- s/Str])
Returns: File

Creates a temporary directory with the given [`dir`  and] prefix

create-temp-file

(create-temp-file prefix suffix)(create-temp-file dir prefix suffix)
Inputs: ([prefix :- s/Str suffix :- (s/maybe s/Str)] [dir :- (s/cond-pre File s/Str Path) prefix :- s/Str suffix :- (s/maybe s/Str)])
Returns: File

Given a Path dir unique ID string (e.g. 'my.dummy.file'), returns a java File object
for a temporary that will be deleted upon JVM exit.

data-input-stream?

(data-input-stream? arg)
Inputs: [arg]

Returns true if arg implements java.io.DataInputStream

data-output-stream?

(data-output-stream? arg)
Inputs: [arg]

Returns true if arg implements java.io.DataOutputStream

delete-directory-recursive

(delete-directory-recursive arg)
Inputs: [arg :- (s/cond-pre s/Str File Path)]

Recursively deletes a directory and all its contents. Returns count of objects deleted.
Idempotent in case dir is already deleted.

delete-file-if-exists

(delete-file-if-exists arg)
Inputs: [arg :- (s/cond-pre s/Str File Path)]
Returns: s/Bool

Deletes a file if it exists. Accepts String, File, or Path arg.

file-exists?

(file-exists? arg)
Inputs: [arg :- (s/cond-pre s/Str File Path)]
Returns: s/Bool

Returns true iff a file exists

File?

(File? arg)
Inputs: [arg :- s/Any]
Returns: s/Bool

Returns true iff arg is a java.io.File

input-stream?

(input-stream? arg)
Inputs: [arg]

Returns true if arg implements java.io.InputStream

mkdirs

(mkdirs arg)
Inputs: [arg :- (s/cond-pre s/Str File Path)]

Creates a directory and all parent dirs.

mkdirs-parent

(mkdirs-parent arg)
Inputs: [arg :- (s/cond-pre s/Str File Path)]

Creates all parent dirs of a file.  Accepts String, File, or Path arg.

output-stream?

(output-stream? arg)
Inputs: [arg]

Returns true if arg implements java.io.OutputStream

Path?

(Path? arg)
Inputs: [arg :- s/Any]
Returns: s/Bool

Returns true iff arg is a java.io.Path

read-byte

(read-byte dis)
Inputs: [dis :- DataInputStream]
Returns: s/Int

Reads 1 byte (signed) from a DataInputStream

read-byte-unsigned

(read-byte-unsigned dis)
Inputs: [dis :- DataInputStream]
Returns: s/Int

Reads 1 byte (unsigned) from a DataInputStream

read-bytes

(read-bytes N input-stream)
Inputs: [N :- s/Int input-stream :- InputStream]

Reads N bytes from a DataInputStream, returning a byte array.

read-double

(read-double dis)
Inputs: [dis :- DataInputStream]
Returns: s/Num

Reads an 8 byte double-precision floating-point value from a DataInputStream

read-float

(read-float dis)
Inputs: [dis :- DataInputStream]
Returns: s/Num

Reads a 4 byte single-precision floating-point value from a DataInputStream

read-integer

(read-integer dis)
Inputs: [dis :- DataInputStream]
Returns: s/Int

Reads 4 bytes (signed) from a DataInputStream

read-integer-unsigned

(read-integer-unsigned dis)
Inputs: [dis :- DataInputStream]
Returns: s/Int

Reads 4 bytes (unsigned) from a DataInputStream

read-long

(read-long dis)
Inputs: [dis :- DataInputStream]
Returns: s/Int

Reads 8 bytes (signed) from a DataInputStream

read-long-unsigned

(read-long-unsigned dis)
Inputs: [dis :- DataInputStream]
Returns: s/Int

Reads 8 bytes (unsigned) from a DataInputStream, returning a BigInteger

read-short

(read-short dis)
Inputs: [dis :- DataInputStream]
Returns: s/Int

Reads 2 bytes (signed) from a DataInputStream

read-short-unsigned

(read-short-unsigned dis)
Inputs: [dis :- DataInputStream]
Returns: s/Int

Reads 2 bytes (unsigned) from a DataInputStream

read-string-bytes

(read-string-bytes nchars dis)
Inputs: [nchars :- s/Int dis :- DataInputStream]
Returns: s/Str

Reads nchars bytes from a DataInputStream, returning a String.

write-byte

(write-byte dos val)
Inputs: [dos :- DataOutputStream val :- s/Int]
Returns: s/Int

Writes 1 byte (signed) to a DataOutputStream.

write-byte-unsigned

(write-byte-unsigned dos val)
Inputs: [dos :- DataOutputStream val :- s/Int]
Returns: s/Int

Writes 1 byte (unsigned) to a DataOutputStream

write-bytes

(write-bytes out-stream bytarr)
Inputs: [out-stream :- OutputStream bytarr :- s/Any]

Writes a byte array to a DataOutputStream.

write-double

(write-double dos val)
Inputs: [dos :- DataOutputStream val :- s/Num]
Returns: s/Num

Writes an 8 byte double-precision floating-point value to a DataInputStream

write-float

(write-float dos val)
Inputs: [dos :- DataOutputStream val :- s/Num]
Returns: s/Num

Writes a 4 byte single-precision floating-point value to a DataInputStream

write-integer

(write-integer dos val)
Inputs: [dos :- DataOutputStream val :- s/Int]
Returns: s/Int

Writes 4 bytes (signed) to a DataOutputStream

write-integer-unsigned

(write-integer-unsigned dos val)
Inputs: [dos :- DataOutputStream val :- s/Int]
Returns: s/Int

Writes 4 bytes (signed) to a DataOutputStream

write-long

(write-long dos val)
Inputs: [dos :- DataOutputStream val :- s/Int]
Returns: s/Int

Writes 8 bytes (signed) to a DataOutputStream

write-long-unsigned

(write-long-unsigned dos val)
Inputs: [dos :- DataOutputStream val :- s/Int]
Returns: s/Int

Writes 8 bytes (unsigned) to a DataOutputStream

write-short

(write-short dos val)
Inputs: [dos :- DataOutputStream val :- s/Int]
Returns: s/Int

Writes 2 bytes (signed) to a DataOutputStream

write-short-unsigned

(write-short-unsigned dos val)
Inputs: [dos :- DataOutputStream val :- s/Int]
Returns: s/Int

Writes 2 bytes (unsigned) to a DataOutputStream

write-string-bytes

(write-string-bytes dos str-val)
Inputs: [dos :- DataOutputStream str-val :- s/Str]
Returns: s/Str

Converts an ASCII String to bytes and writes them to a DataInputStream (w/o length header).