Package

org.opalj

io

Permalink

package io

Various io-related helper methods and classes.

Note

The implementations of the methods rely on Java NIO(2).

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. io
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. class FailAfterByteArrayOutputStream extends ByteArrayOutputStream

    Permalink

    A java.io.ByteArrayOutputStream that throws an exception after writing some bytes, if the given boudary (failAfter) is surpased.

  2. case class OpeningFileFailedException(file: File, cause: Throwable) extends Exception with Product with Serializable

    Permalink

    Exception that is thrown if the OS cannot/does not know how/is not able to open the respective file.

Value Members

  1. def process[C <: Closeable, T](closable: C)(r: (C) ⇒ T): T

    Permalink

    This function takes a Closeable resource and a function r that will process the Closeable resource.

    This function takes a Closeable resource and a function r that will process the Closeable resource. This function takes care of the correct handling of Closeable resources. When r has finished processing the resource or throws an exception, the resource is closed.

    closable

    The Closeable resource.

    r

    The function that processes the resource.

    Note

    If closable is null, null is passed to r.

  2. def processSource[C <: Source, T](source: C)(r: (C) ⇒ T): T

    Permalink

    This function takes a Source object and a function r that will process the source.

    This function takes a Source object and a function r that will process the source. This function takes care of the correct handling of resources. When r has finished processing the source or throws an exception, the source is closed.

    Note

    If source is null, null is passed to r.

  3. def write(data: Array[Byte], path: Path): Unit

    Permalink

    A simple wrapper for java.nio.Files.write(Path,byte[]).

  4. def write(data: String, filenamePrefix: String, filenameSuffix: String): Path

    Permalink
  5. def writeAndOpen(data: String, filenamePrefix: String, filenameSuffix: String): File

    Permalink

    Writes the given string (data) to a temporary file using the given prefix and suffix.

    Writes the given string (data) to a temporary file using the given prefix and suffix. Afterwards the system's native application that claims to be able to handle files with the given suffix is opened. If this fails, the string is printed to the console.

    The string is always written using UTF-8 as the encoding.

    filenamePrefix

    A string the identifies the content of the file. (E.g., "ClassHierarchy" or "CHACallGraph")

    filenameSuffix

    The suffix of the file that identifies the used file format. (E.g., ".txt")

    returns

    The name of the file if it was possible to write the file and open the native application.

    Annotations
    @throws( ... ) @throws( ... )
    Example:
    1. Exemplary usage:

      try {
          util.writeAndOpen("The Message", "Result", ".txt")
      } catch {
          case OpeningFileFailedException(file, _) ⇒
              Console.err.println("Details can be found in: "+file.toString)
  6. def writeAndOpen(node: Node, filenamePrefix: String, filenameSuffix: String): File

    Permalink

    Writes the XML document to a temporary file and opens the file in the OS's default application.

    Writes the XML document to a temporary file and opens the file in the OS's default application.

    filenamePrefix

    A string the identifies the content of the file. (E.g., "ClassHierarchy" or "CHACallGraph")

    filenameSuffix

    The suffix of the file that identifies the used file format. (E.g., ".xhtml")

    returns

    The name of the file if it was possible to write the file and open the native application.

    Annotations
    @throws( ... ) @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped