Skip to content

Latest commit

 

History

History
73 lines (51 loc) · 1.81 KB

README.md

File metadata and controls

73 lines (51 loc) · 1.81 KB

Java Io Extras

This is a library for extra integrations between Scala and java.io that should make working with java.io a little bit easier in Scala.

Features

Integrations for java.io.InputStream

Usage:

import com.github.joshlemer.java_io_extras._
import java.io.InputStream

// get an InputStream from somewhere
val inputStream: InputStream = ???

// convert it to `Iterator[Byte]`
val iterator: Iterator[Byte] = InputStreamIterator(inputStream)

// convert an Iterator[Byte] to an InputStream
val inputStream2: InputStream = IteratorInputStream(iterator)

or you can use the supplied implicit converters:

import com.github.joshlemer.java_io_extras._
import com.github.joshlemer.java_io_extras.Converters._
import java.io.InputStream

// get an InputStream from somewhere
val inputStream: InputStream = ???

// convert it to `Iterator[Byte]`
val iterator: Iterator[Byte] = inputStream.iterator

// convert an Iterator[Byte] to an InputStream
val inputStream2: InputStream = iterator.inputStream

Integrations for java.io.Reader

Usage:

import com.github.joshlemer.java_io_extras._
import java.io.Reader

// get an InputStream from somewhere
val reader: InputStream = ???

// convert it to `Iterator[Byte]`
val iterator: Iterator[Byte] = InputStreamIterator(inputStream)

// convert an Iterator[Byte] to an InputStream
val inputStream2: InputStream = IteratorInputStream(iterator)

or you can use the supplied implicit converters:

import com.github.joshlemer.java_io_extras._
import com.github.joshlemer.java_io_extras.Converters._
import java.io.Reader

// get an InputStream from somewhere
val reader: Reader =

// convert it to `Iterator[Char]`
val iterator: Iterator[Char] = reader.iterator

// convert an Iterator[Char] to a Reader
val reader2: Reader = iterator.reader