Packages

p

fileutils

package fileutils

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

Value Members

  1. def appendToFile(file: File, data: String): Unit

    Appends text to file.

    Appends text to file. Opens a new java.io.FileWriter on every call.

  2. def appendToFile(fileName: String, textData: String): Unit

    Appends text to file.

    Appends text to file. Opens a new java.io.FileWriter on every call.

  3. def cat(in: Iterable[File], out: File, header: Int = 0): Unit

    Concatenates text files together, dropping header lines for each, except the first.

  4. def createSource(s: File)(implicit codec: Codec): BufferedSource
  5. def createSourceFromZippedFile(file: String, bufferSize: Int = io.Source.DefaultBufSize)(implicit codec: Codec): BufferedSource

    Returns a scala.io.Source from the given GZipped file.

  6. def createSymbolicLink(from: File, to: File): File
  7. def exec(pb: ProcessBuilder, atMost: Duration = Duration.Inf, retries: Int = 0)(stdOutFunc: (String) ⇒ Unit = x: String =>)(implicit stdErrFunc: (String) ⇒ Unit = (x: String) => ()): Int

    Execute command with user function to process each line of output.

    Execute command with user function to process each line of output.

    Based on from http://www.jroller.com/thebugslayer/entry/executing_external_system_commands_in Creates 3 new threads: one for the stdout, one for the stderror, and one waits for the exit code.

    pb

    Description of the executable process

    atMost

    Maximum time to wait for the process to complete. Default infinite.

    returns

    Exit code of the process.

  8. def execGetStreamsAndCode(pb: ProcessBuilder, unsuccessfulOnErrorStream: Boolean = true, atMost: Duration = Duration.Inf, retries: Int = 0): (List[String], List[String], Boolean)

    Execute command.

    Execute command. Returns stdout and stderr as strings, and true if it was successful.

    A process is considered successful if its exit code is 0 and the error stream is empty. The latter criterion can be disabled with the unsuccessfulOnErrorStream parameter.

    pb

    The process description.

    unsuccessfulOnErrorStream

    if true, then the process is considered as a failure if its stderr is not empty.

    atMost

    max waiting time.

    returns

    (stdout,stderr,success) triples

  9. def execGetStreamsAndCodeWithLog(pb: ProcessBuilder, unsuccessfulOnErrorStream: Boolean = true, atMost: Duration = Duration.Inf, retries: Int = 0)(implicit log: AnyRef { ... /* 2 definitions in type refinement */ }): (List[String], List[String], Boolean)

    Execute command.

    Execute command. Returns stdout and stderr as strings, and true if it was successful. Also writes to log.

    A process is considered successful if its exit code is 0 and the error stream is empty. The latter criterion can be disabled with the unsuccessfulOnErrorStream parameter.

    pb

    The process description.

    unsuccessfulOnErrorStream

    if true, then the process is considered as a failure if its stderr is not empty.

    atMost

    max waiting time.

    log

    A logger.

    returns

    (stdout,stderr,success) triples

  10. def fileIsEmpty(file: File): Boolean

    Returns true if file is empty.

  11. def getFileReader(fileName: File): BufferedReader

    Returns a java.io.BufferedReader.

  12. def getFileWriter(fileName: File, append: Boolean = false): BufferedWriter

    Returns a java.io.BufferedWriter.

  13. def isGZipFile(file: File): Boolean

    Returns true if the file is GZipped.

  14. def isGZipFile(file: String): Boolean

    Returns true if the file is GZipped.

  15. def openFileInputStream[T](fileName: File)(func: (BufferedInputStream) ⇒ T): T

    Opens a buffered java.io.BufferedInputStream on the file.

    Opens a buffered java.io.BufferedInputStream on the file. Closes it after the block is executed.

  16. def openFileInputStreamMaybeZipped[T](file: File)(func: (InputStream) ⇒ T): T
  17. def openFileOutputStream[T](func: (BufferedOutputStream) ⇒ T): (File, T)

    Opens a buffered java.io.BufferedOutputStream on the file.

    Opens a buffered java.io.BufferedOutputStream on the file. Closes it after the block is executed.

  18. def openFileOutputStream[T](fileName: File, append: Boolean = false)(func: (BufferedOutputStream) ⇒ T): T

    Opens a buffered java.io.BufferedOutputStream on the file.

    Opens a buffered java.io.BufferedOutputStream on the file. Closes it after the block is executed.

  19. def openFileReader[T](fileName: File)(func: (BufferedReader) ⇒ T): T

    Opens a buffered java.io.BufferedReader on the file.

    Opens a buffered java.io.BufferedReader on the file. Closes it after the block is executed.

  20. def openFileWriter[T](func: (BufferedWriter) ⇒ T): (File, T)
  21. def openFileWriter[T](fileName: File, append: Boolean = false)(func: (BufferedWriter) ⇒ T): T

    Opens a java.io.BufferedWriter on the file.

    Opens a java.io.BufferedWriter on the file. Closes it after the block is executed.

  22. def openSource[A](s: File)(f: (Source) ⇒ A)(implicit codec: Codec): A

    Opens a scala.io.Source, executes the block, then closes the source.

    Opens a scala.io.Source, executes the block, then closes the source.

    s

    Path of the file

  23. def openSource[A](s: String)(f: (Source) ⇒ A)(implicit codec: Codec): A

    Opens a scala.io.Source, executes the block, then closes the source.

    Opens a scala.io.Source, executes the block, then closes the source.

    s

    Path of the file

  24. def openUnbufferedFileWriter[T](fileName: File, append: Boolean = false)(func: (Writer) ⇒ T): T

    Opens an unbuffered java.io.Writer on the file.

    Opens an unbuffered java.io.Writer on the file. Closes it after the block is executed.

  25. def openZippedFileInputStream[T](fileName: File)(func: (InputStream) ⇒ T): T

    Opens a java.io.OutputStream which writes GZip compressed data to the given path.

    Opens a java.io.OutputStream which writes GZip compressed data to the given path. Closes it after the block is executed.

  26. def openZippedFileOutputStream[T](func: (OutputStream) ⇒ T): (File, T)
  27. def openZippedFileOutputStream[T](fileName: File, append: Boolean = false)(func: (OutputStream) ⇒ T): T

    Opens a java.io.OutputStream which writes GZip compressed data to the given path.

    Opens a java.io.OutputStream which writes GZip compressed data to the given path. Closes it after the block is executed.

  28. def openZippedFileReader[T](fileName: File)(func: (BufferedReader) ⇒ T): T

    Opens a java.io.BufferedReader on a GZipped file.

    Opens a java.io.BufferedReader on a GZipped file. Closes it after the block is executed.

  29. def openZippedFileWriter[T](func: (Writer) ⇒ T): (File, T)
  30. def openZippedFileWriter[T](fileName: File, append: Boolean = false)(func: (Writer) ⇒ T): T

    Opens a java.io.BufferedWriter which writes GZip compressed data to the given path.

    Opens a java.io.BufferedWriter which writes GZip compressed data to the given path. Closes it after the block is executed.

  31. def putBesides(filesWithExtensions: (File, String)*): File

    Creates symbolic links with the same basename but different extensions.

    Creates symbolic links with the same basename but different extensions.

    filesWithExtensions

    files with the needed extensions

    returns

    A temporary File which points to the common part of the symbolic links paths.

  32. def readBinaryFile(f: File): Array[Byte]

    Reads file contents into a bytearray.

  33. def readBinaryFile(fileName: String): Array[Byte]

    Reads file contents into a bytearray.

  34. def readBinaryStream(f: InputStream): Array[Byte]

    Reads file contents into a bytearray.

  35. def readLines(s: File): Vector[String]
  36. def readLines(s: String): Vector[String]
  37. def readStreamAndClose(is: InputStream): Iterator[Byte] { ... /* 2 definitions in type refinement */ }

    Returns an iterator on the InputStream's data.

    Returns an iterator on the InputStream's data.

    Closes the stream when read through.

  38. def searchForFileInPath(fileName: String): Boolean

    Searches $PATH for the specified file

  39. implicit def stringSeqToProcess(command: Seq[String]): ProcessBuilder
  40. implicit def stringToProcess(command: String): ProcessBuilder
  41. def useResource[A <: AnyRef { def close(): Unit }, B](param: A)(f: (A) ⇒ B): B

    Returns the result of the block, and closes the resource.

    Returns the result of the block, and closes the resource.

    param

    closeable resource

    f

    block using the resource

  42. def using[A <: AnyRef { def close(): Unit }, B]: (A) ⇒ ((A) ⇒ B) ⇒ B

    Alias for useResource

  43. def writeBinaryToFile(file: File, data: Array[Byte]): Unit

    Writes binary data to file.

  44. def writeBinaryToFile(fileName: String, data: Array[Byte]): Unit

    Writes binary data to file.

  45. def writeBinaryToTempFile(data: Array[Byte]): File
  46. def writeByteBufferToFile(file: File, buff: ByteBuffer): Unit

    Writes the ByteBuffer's contents to a file.

  47. def writeByteBufferToFile(fileName: String, buff: ByteBuffer): Unit

    Writes the ByteBuffer's contents to a file.

  48. def writeToFile(file: File, data: String): Unit

    Writes text data to file.

  49. def writeToFile(fileName: String, data: String): Unit

    Writes text data to file.

  50. def writeToTempFile(data: String): File
  51. object TempFile

Inherited from AnyRef

Inherited from Any

Ungrouped