o

sbt.io

IO

object IO

A collection of File, URL, and I/O utility methods.

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

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. val Newline: String

    The newline string for this system, as obtained by the line.separator system property.

  5. def append(file: File, bytes: Array[Byte]): Unit

    Appends bytes to the existing contents of file.

    Appends bytes to the existing contents of file. If file does not exist, it is created, as are any parent directories.

  6. def append(file: File, content: String, charset: Charset = defaultCharset): Unit

    Appends content to the existing contents of file using charset or UTF-8 if charset is not explicitly specified.

    Appends content to the existing contents of file using charset or UTF-8 if charset is not explicitly specified. If file does not exist, it is created, as are any parent directories.

  7. def asFile(url: URL): File

    Converts the given URL to a File.

    Converts the given URL to a File. If the URL is for an entry in a jar, the File for the jar is returned.

  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def assertAbsolute(uri: URI): Unit
  10. def assertAbsolute(f: File): Unit
  11. def assertDirectories(file: File*): Unit
  12. def assertDirectory(file: File): Unit
  13. def chgrp(group: String, file: File): Unit

    An alias for setGroup.

    An alias for setGroup. Updates the group owner of the file. This operation requires underlying filesystem to support IO.hasFileOwnerAttributeView.

  14. def chmod(permissions: String, file: File): Unit

    An alias for setPermissions.

    An alias for setPermissions. Updates permission of this file. This operation requires underlying filesystem to support IO.isPosix.

    permissions

    Must be 9 character POSIX permission representation e.g. "rwxr-x---"

  15. def chown(owner: String, file: File): Unit

    An alias for setOwner.

    An alias for setOwner. Updates the file owner. This operation requires underlying filesystem to support IO.hasFileOwnerAttributeView.

  16. def classLocationFile[T](implicit mf: Manifest[T]): File

    Returns the directory or jar file containing the class file for type T (as determined by an implicit Manifest).

    Returns the directory or jar file containing the class file for type T (as determined by an implicit Manifest). If the location cannot be determined, an error is generated. Note that Java standard library classes typically do not have a location associated with them.

  17. def classLocationFile(cl: Class[_]): File

    Returns the directory or jar file containing the class file cl.

    Returns the directory or jar file containing the class file cl. If the location cannot be determined or it is not a file, an error is generated. Note that Java standard library classes typically do not have a location associated with them.

  18. def classfileLocation(cl: Class[_]): URL

    Returns a URL for the classfile containing the given class If the location cannot be determined, an error is generated.

  19. def classfileLocation[T](implicit mf: Manifest[T]): URL

    Returns a URL for the classfile containing the given class file for type T (as determined by an implicit Manifest).

    Returns a URL for the classfile containing the given class file for type T (as determined by an implicit Manifest). If the location cannot be determined, an error is generated.

  20. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. def copy(sources: Traversable[(File, File)], overwrite: Boolean, preserveLastModified: Boolean, preserveExecutable: Boolean): Set[File]
  22. def copy(sources: Traversable[(File, File)], options: CopyOptions): Set[File]

    For each pair in sources, copies the contents of the first File (the source) to the location of the second File (the target).

    For each pair in sources, copies the contents of the first File (the source) to the location of the second File (the target).

    See sbt.io.CopyOptions for docs on the options available.

    Any parent directories that do not exist are created. The set of all target files is returned, whether or not they were updated by this method.

  23. def copy(sources: Traversable[(File, File)]): Set[File]
  24. def copyDirectory(source: File, target: File, overwrite: Boolean = false, preserveLastModified: Boolean = false, preserveExecutable: Boolean = true): Unit
  25. def copyDirectory(source: File, target: File, options: CopyOptions): Unit

    Copies the contents of each file in the source directory to the corresponding file in the target directory.

    Copies the contents of each file in the source directory to the corresponding file in the target directory.

    See sbt.io.CopyOptions for docs on the options available.

    Files in target without a corresponding file in source are left unmodified in any case. Any parent directories that do not exist are created.

  26. def copyDirectory(source: File, target: File): Unit
  27. def copyExecutable(sourceFile: File, targetFile: File): AnyVal

    Transfers the executable property of sourceFile to targetFile.

  28. def copyFile(sourceFile: File, targetFile: File, preserveLastModified: Boolean = false, preserveExecutable: Boolean = true): Unit
  29. def copyFile(sourceFile: File, targetFile: File, options: CopyOptions): Unit

    Copies the contents of sourceFile to the location of targetFile, overwriting any existing content.

    Copies the contents of sourceFile to the location of targetFile, overwriting any existing content.

    See sbt.io.CopyOptions for docs on the options available.

  30. def copyFile(sourceFile: File, targetFile: File): Unit
  31. def copyLastModified(sourceFile: File, targetFile: File): Boolean

    Transfers the last modified time of sourceFile to targetFile.

  32. def createDirectories(dirs: Traversable[File]): Unit

    Creates directories dirs and all parent directories.

    Creates directories dirs and all parent directories. It tries to work around a race condition in File.mkdirs() by retrying up to a limit.

  33. def createDirectory(dir: File): Unit

    Creates directory dir and all parent directories.

    Creates directory dir and all parent directories. It tries to work around a race condition in File.mkdirs() by retrying up to a limit.

  34. def createTemporaryDirectory: File

    Creates a directory in the default temporary directory with a name generated from a random integer.

  35. def createUniqueDirectory(baseDirectory: File): File

    Creates a directory in baseDirectory with a name generated from a random integer

  36. def defaultCharset: Charset

    The default Charset used when not specified: UTF-8.

  37. def delete(file: File): Unit

    Deletes file, recursively if it is a directory.

  38. def delete(files: Iterable[File]): Unit

    Deletes each file or directory (recursively) in files.

  39. def deleteFilesEmptyDirs(files: Iterable[File]): Unit

    Deletes each file or directory in files recursively.

    Deletes each file or directory in files recursively. Any empty parent directories are deleted, recursively.

  40. def deleteIfEmpty(dirs: Set[File]): Unit

    Deletes all empty directories in the set.

    Deletes all empty directories in the set. Any non-empty directories are ignored.

  41. def directoryURI(uri: URI): URI

    Converts an absolute File to a URI.

    Converts an absolute File to a URI. The File is converted to a URI (toURI), normalized (normalize), encoded (toASCIIString), and a forward slash ('/') is appended to the path component if it does not already end with a slash.

  42. def directoryURI(dir: File): URI

    Converts an absolute File to a URI.

    Converts an absolute File to a URI. The File is converted to a URI (toURI), normalized (normalize), encoded (toASCIIString), and a forward slash ('/') is appended to the path component if it does not already end with a slash.

  43. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  44. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  45. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  46. def foldLines[T](in: BufferedReader, init: T)(f: (T, String) ⇒ T): T

    Applies f to each line read from in and the accumulated value of type T, with initial value init.

    Applies f to each line read from in and the accumulated value of type T, with initial value init. This method does not close in.

  47. def foreachLine(in: BufferedReader)(f: (String) ⇒ Unit): Unit

    Applies f to each line read from in.

    Applies f to each line read from in. This method does not close in.

  48. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  49. def gunzip(input: InputStream, output: OutputStream): Unit

    Gunzips the InputStream 'input' and writes it to 'output'.

    Gunzips the InputStream 'input' and writes it to 'output'. Neither stream is closed.

  50. def gunzip(in: File, out: File): Unit

    Gunzips the file 'in' and writes it to 'out'.

    Gunzips the file 'in' and writes it to 'out'. 'in' cannot be the same file as 'out'.

  51. def gzip(input: InputStream, output: OutputStream): Unit

    Gzips the InputStream 'in' and writes it to 'output'.

    Gzips the InputStream 'in' and writes it to 'output'. Neither stream is closed.

  52. def gzip(in: File, out: File): Unit

    Gzips the file 'in' and writes it to 'out'.

    Gzips the file 'in' and writes it to 'out'. 'in' cannot be the same file as 'out'.

  53. def gzipFileIn[T](file: File)(f: (InputStream) ⇒ T): T

    Applies f to a buffered gzip InputStream for file.

    Applies f to a buffered gzip InputStream for file. The streams involved are opened before calling f and closed after it returns. The result is the result of f.

  54. def gzipFileOut[T](file: File)(f: (OutputStream) ⇒ T): T

    Applies f to a buffered gzip OutputStream for file.

    Applies f to a buffered gzip OutputStream for file. The streams involved are opened before calling f and closed after it returns. The result is the result of f.

  55. lazy val hasAclFileAttributeView: Boolean

    Returns true if the filesystem supports ACL file attribute view.

  56. lazy val hasBasicFileAttributeView: Boolean

    Returns true if the filesystem supports basic file attribute view.

  57. lazy val hasDosFileAttributeView: Boolean

    Returns true if the filesystem supports DOS file attribute view.

  58. lazy val hasFileOwnerAttributeView: Boolean

    Returns true if the filesystem supports file owner attribute view.

  59. lazy val hasPosixFileAttributeView: Boolean

    Returns true if the filesystem supports POSIX file attribute view.

  60. lazy val hasUserDefinedFileAttributeView: Boolean

    Returns true if the filesystem supports user-defined file attribute view.

  61. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  62. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  63. def isPosix: Boolean

    Returns true if the filesystem supports POSIX file attribute view.

  64. def jar(sources: Traversable[(File, String)], outputJar: File, manifest: Manifest): Unit

    Creates a jar file.

    Creates a jar file.

    sources

    The files to include in the jar file paired with the entry name in the jar. Only the pairs explicitly listed are included.

    outputJar

    The file to write the jar to.

    manifest

    The manifest for the jar.

  65. def listFiles(dir: File): Array[File]

    Returns the children of directory dir in a non-null array.

  66. def listFiles(dir: File, filter: java.io.FileFilter): Array[File]

    Returns the children of directory dir that match filter in a non-null array.

  67. def listFiles(filter: java.io.FileFilter)(dir: File): Array[File]

    Returns the children of directory dir that match filter in a non-null array.

  68. def load(properties: Properties, from: File): Unit

    Reads the properties in from into properties.

    Reads the properties in from into properties. If from does not exist, properties is left unchanged.

  69. def move(a: File, b: File): Unit

    Moves the contents of a to the location specified by b.

    Moves the contents of a to the location specified by b. This method deletes any content already at b and creates any parent directories of b if they do not exist. It will first try File.renameTo and if that fails, resort to copying and then deleting the original file. In either case, the original File will not exist on successful completion of this method.

  70. def move(files: Traversable[(File, File)]): Unit

    For each pair in files, moves the contents of the first File to the location of the second.

    For each pair in files, moves the contents of the first File to the location of the second. See sbt.io.IO$.move(java.io.File,java.io.File):Unit for the behavior of the individual move operations.

  71. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  72. final def notify(): Unit
    Definition Classes
    AnyRef
  73. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  74. def objectInputStream(wrapped: InputStream, loader: ClassLoader): ObjectInputStream

    Constructs an ObjectInputStream on wrapped that uses loader to load classes.

    Constructs an ObjectInputStream on wrapped that uses loader to load classes. See also issue 136.

  75. def parseClasspath(s: String): Seq[File]

    Parses a classpath String into File entries according to the current platform's path separator.

  76. def pathSplit(s: String): Array[String]

    Splits a String around the platform's path separator characters.

  77. def read(file: File, charset: Charset = defaultCharset): String

    Reads the full contents of file into a String using charset or UTF-8 if charset is not explicitly specified.

  78. def readBytes(in: InputStream): Array[Byte]

    Reads the full contents of in into a byte array.

    Reads the full contents of in into a byte array. This method does not close in.

  79. def readBytes(file: File): Array[Byte]

    Reads the full contents of in into a byte array.

  80. def readLines(in: BufferedReader): List[String]

    Reads all of the lines from in.

    Reads all of the lines from in. This method does not close in.

  81. def readLines(file: File, charset: Charset = defaultCharset): List[String]

    Reads all of the lines in file using the provided charset or UTF-8 if charset is not explicitly specified.

  82. def readLinesURL(url: URL, charset: Charset = defaultCharset): List[String]

    Reads all of the lines from url using the provided charset or UTF-8 if charset is not explicitly specified.

  83. def readStream(in: InputStream, charset: Charset = defaultCharset): String

    Reads the full contents of in into a byte array.

    Reads the full contents of in into a byte array. This method does not close in.

  84. def reader[T](file: File, charset: Charset = defaultCharset)(f: (BufferedReader) ⇒ T): T
  85. def relativize(base: File, file: File): Option[String]

    Returns the path for file relative to directory base or None if base is not a parent of file.

    Returns the path for file relative to directory base or None if base is not a parent of file. If file or base are not absolute, they are first resolved against the current working directory.

  86. def relativizeFile(base: File, file: File): Option[File]

    Returns the relative file for file relative to directory base or None if base is not a parent of file.

    Returns the relative file for file relative to directory base or None if base is not a parent of file. If file or base are not absolute, they are first resolved against the current working directory.

  87. def resolve(base: File, f: File): File

    Resolves f against base, which must be an absolute directory.

    Resolves f against base, which must be an absolute directory. The result is guaranteed to be absolute. If f is absolute, it is returned without changes.

  88. def setGroup(file: File, group: String): Unit

    Updates the group owner of the file.

    Updates the group owner of the file. This operation requires underlying filesystem to support IO.hasFileOwnerAttributeView.

  89. def setOwner(file: File, owner: String): Unit

    Updates the file owner.

    Updates the file owner. This operation requires underlying filesystem to support IO.hasFileOwnerAttributeView.

  90. def setPermissions(file: File, permissions: String): Unit

    Updates permission of this file.

    Updates permission of this file. This operation requires underlying filesystem to support IO.isPosix.

    permissions

    Must be 9 character POSIX permission representation e.g. "rwxr-x---"

  91. def split(name: String): (String, String)

    Splits the given string into base and extension strings.

    Splits the given string into base and extension strings. If name contains no period, the base string is the input string and the extension is the empty string. Otherwise, the base is the substring up until the last period (exclusive) and the extension is the substring after the last period.

    For example, split("Build.scala") == ("Build", "scala")

  92. def stash[T](files: Set[File])(f: ⇒ T): T

    Move the provided files to a temporary location.

    Move the provided files to a temporary location. If 'f' returns normally, delete the files. If 'f' throws an Exception, return the files to their original location.

  93. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  94. val temporaryDirectory: File
  95. def toFile(url: URL): File

    Constructs a File corresponding to url, which must have a scheme of file.

    Constructs a File corresponding to url, which must have a scheme of file. This method properly works around an issue with a simple conversion to URI and then to a File.

    On Windows this can accept the following patterns of URLs:

    val u0 = new URL("file:C:\\Users\\foo/.sbt/preloaded"), val u1 = new URL("file:/C:\\Users\\foo/.sbt/preloaded"), val u2 = new URL("file://unc/Users/foo/.sbt/preloaded"), val u3 = new URL("file:///C:\\Users\\foo/.sbt/preloaded"), and val u4 = new URL("file:////unc/Users/foo/.sbt/preloaded").

  96. def toString(): String
    Definition Classes
    AnyRef → Any
  97. def toURI(f: File): URI

    Converts the given File to a URI.

    Converts the given File to a URI. If the File is relative, the URI is relative, unlike File.toURI

  98. def touch(file: File, setModified: Boolean = true): Unit

    Creates a file at the given location if it doesn't exist.

    Creates a file at the given location if it doesn't exist. If the file already exists and setModified is true, this method sets the last modified time to the current time.

  99. def touch(files: Traversable[File]): Unit

    Each input file in files is created if it doesn't exist.

    Each input file in files is created if it doesn't exist. If a file already exists, the last modified time is set to the current time. It is not guaranteed that all files will have the same last modified time after this call.

  100. def transfer(in: InputStream, out: OutputStream): Unit

    Copies all bytes from the given input stream to the given output stream.

    Copies all bytes from the given input stream to the given output stream. Neither stream is closed.

  101. def transfer(in: InputStream, to: File): Unit

    Copies all bytes from the given input stream to the given File.

    Copies all bytes from the given input stream to the given File. The input stream is not closed by this method.

  102. def transfer(in: File, out: OutputStream): Unit

    Copies the contents of the input file in to the out stream.

    Copies the contents of the input file in to the out stream. The output stream is not closed by this method.

  103. def transfer(in: File, out: File): Unit

    Copies the contents of in to out.

  104. def transferAndClose(in: InputStream, out: OutputStream): Unit

    Copies all bytes from the given input stream to the given output stream.

    Copies all bytes from the given input stream to the given output stream. The input stream is closed after the method completes.

  105. def unzip(from: File, toDirectory: File, filter: NameFilter = AllPassFilter, preserveLastModified: Boolean = true): Set[File]
  106. def unzipStream(from: InputStream, toDirectory: File, filter: NameFilter = AllPassFilter, preserveLastModified: Boolean = true): Set[File]
  107. def unzipURL(from: URL, toDirectory: File, filter: NameFilter = AllPassFilter, preserveLastModified: Boolean = true): Set[File]
  108. def urlAsFile(url: URL): Option[File]
  109. val utf8: Charset
  110. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  111. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  112. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  113. def withTemporaryDirectory[T](action: (File) ⇒ T): T

    Overload of withTemporaryDirectory with keepDirectory set to false.

  114. def withTemporaryDirectory[T](action: (File) ⇒ T, keepDirectory: Boolean): T

    Creates a temporary directory and provides its location to the given function.

    Creates a temporary directory and provides its location to the given function. The directory is deleted after the function returns if keepDirectory is set to false.

  115. def withTemporaryFile[T](prefix: String, postfix: String)(action: (File) ⇒ T): T

    Overload of withTemporaryFile with keepFile set to false.

  116. def withTemporaryFile[T](prefix: String, postfix: String, keepFile: Boolean)(action: (File) ⇒ T): T

    Creates a file in the default temporary directory, calls action with the file, deletes the file if keepFile is set to true, and returns the result of calling action.

    Creates a file in the default temporary directory, calls action with the file, deletes the file if keepFile is set to true, and returns the result of calling action. The name of the file will begin with prefix, which must be at least three characters long, and end with postfix, which has no minimum length.

  117. def write(properties: Properties, label: String, to: File): Unit

    Writes properties to the File to, using label as the comment on the first line.

    Writes properties to the File to, using label as the comment on the first line. If any parent directories of to do not exist, they are first created.

  118. def write(file: File, bytes: Array[Byte]): Unit

    Writes bytes to file, overwriting any existing content.

    Writes bytes to file, overwriting any existing content. If any parent directories do not exist, they are first created.

  119. def write(file: File, content: String, charset: Charset = defaultCharset, append: Boolean = false): Unit

    Writes content to file using charset or UTF-8 if charset is not explicitly specified.

    Writes content to file using charset or UTF-8 if charset is not explicitly specified. If append is false, the existing contents of file are overwritten. If append is true, the new content is appended to the existing contents. If file or any parent directories do not exist, they are created.

  120. def writeLines(writer: PrintWriter, lines: Seq[String]): Unit

    Writes lines to writer using writer's println method.

  121. def writeLines(file: File, lines: Seq[String], charset: Charset = defaultCharset, append: Boolean = false): Unit

    Writes lines to file using the given charset or UTF-8 if charset is not explicitly specified.

    Writes lines to file using the given charset or UTF-8 if charset is not explicitly specified. If append is false, the contents of the file are overwritten. If append is true, the lines are appended to the file. A newline is written after each line and NOT before the first line. If any parent directories of file do not exist, they are first created.

  122. def writer[T](file: File, content: String, charset: Charset, append: Boolean = false)(f: (BufferedWriter) ⇒ T): T
  123. def zip(sources: Traversable[(File, String)], outputZip: File): Unit

    Creates a zip file.

    Creates a zip file.

    sources

    The files to include in the zip file paired with the entry name in the zip. Only the pairs explicitly listed are included.

    outputZip

    The file to write the zip to.

Inherited from AnyRef

Inherited from Any

Ungrouped