org.scalatra.util.io

A collection of I/O utility methods.

Type members

Classlikes

Value members

Concrete methods

def copy(in: InputStream, out: OutputStream, bufferSize: Int): Unit

Copies the input stream to the output stream.

Copies the input stream to the output stream.

Value parameters:
bufferSize

the size of buffer to use for each read

in

the input stream to read. The InputStream will be closed, unlike commons-io's version.

out

the output stream to write

def readBytes(in: InputStream): Array[Byte]
def using[A, B <: AutoCloseable](closeable: B)(f: B => A): A

Executes a block with a closeable resource, and closes it after the block runs

Executes a block with a closeable resource, and closes it after the block runs

Type parameters:
A

the return type of the block

B

the closeable resource type

Value parameters:
closeable

the closeable resource

f

the block

def withTempFile[A](content: String, prefix: String, suffix: String, directory: Option[File])(f: File => A): A

Creates a temp file, passes it to a block, and removes the temp file on the block's completion.

Creates a temp file, passes it to a block, and removes the temp file on the block's completion.

Type parameters:
A

the return type of the block

Value parameters:
content

The content of the file

directory

The directory of the temp file; a system dependent temp directory if None

f

the block

prefix

The prefix of the temp file; must be at least three characters long

suffix

The suffix of the temp file

Returns:

the result of f

def zeroCopy(in: FileInputStream, out: OutputStream): Unit