com.mattg.util

FileUtil

class FileUtil extends AnyRef

This class serves two main purposes:

It might make sense to split these two purposes out into separate classes, but that's not a big deal to me right now, so they will stay as they are. There's also some overlap - if this were two classes, the one that does file manipulation would need to call the file system interface.

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. FileUtil
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new FileUtil()

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 _chunkSize: Int

  5. def addDirectorySeparatorIfNecessary(dirName: String): String

  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def blockOnFileDeletion(filename: String): Unit

  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def copy(from: String, to: String): Unit

  10. def copyLines(reader: BufferedReader, writer: FileWriter): Unit

    Copies the lines in reader to writer.

    Copies the lines in reader to writer. Does not close writer.

  11. val countWords: (String) ⇒ Seq[String]

  12. def deleteDirectory(dirname: String): Unit

  13. def deleteFile(filename: String): Unit

  14. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  16. def fileExists(path: String): Boolean

  17. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. def flatMapLinesFromFile[T](filename: String, function: (String) ⇒ Seq[T]): Seq[T]

  19. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  20. def getCountsFromFile[T](filename: String, f: (String) ⇒ Seq[T], chunkSize: Int = _chunkSize): Map[T, Int]

  21. def getDataInputStream(filename: String): DataInputStream

  22. def getDataOutputStream(filename: String): DataOutputStream

  23. def getFileWriter(filename: String, append: Boolean = false): FileWriter

  24. def getLineIterator[T](stream: InputStream, f: (String) ⇒ T): Iterator[T]

  25. def getLineIterator[T](file: File, f: (String) ⇒ T): Iterator[T]

  26. def getLineIterator[T](filename: String, f: (String) ⇒ T): Iterator[T]

  27. def getLineIterator(stream: InputStream): Iterator[String]

  28. def getLineIterator(file: File): Iterator[String]

  29. def getLineIterator(filename: String): Iterator[String]

  30. def getTimestamp(filename: String): Long

  31. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  32. def intTripleFromLine[T](line: String, f: (Int, Int, Int) ⇒ T = returnTriple): T

  33. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  34. def listDirectoryContents(filename: String): Seq[String]

  35. def logEvery(logFrequency: Int, current: Int, toLog: String): Unit

  36. def logEvery(logFrequency: Int, current: Int): Unit

  37. def mapLinesFromFile[T](filename: String, function: (String) ⇒ T): Seq[T]

  38. def mkdirOrDie(dirName: String): Unit

    Attempts to create the directory dirName, and exits if the directory already exists.

  39. def mkdirs(dirName: String): Unit

    Calls new File(dirName).mkdirs().

  40. def mkdirsForFile(filename: String): Unit

    Calls mkdirs on the parent of this file.

  41. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  42. final def notify(): Unit

    Definition Classes
    AnyRef
  43. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  44. def parFlatMapLinesFromFile[T](filename: String, function: (String) ⇒ Seq[T], chunkSize: Int = _chunkSize): Seq[T]

  45. def parMapLinesFromFile[T](filename: String, function: (String) ⇒ T, chunkSize: Int = _chunkSize): Seq[T]

  46. def parProcessFile(iterator: Iterator[String], f: (String) ⇒ Unit, chunkSize: Int = _chunkSize): Unit

  47. def parProcessFile(stream: InputStream, f: (String) ⇒ Unit): Unit

  48. def parProcessFile(file: File, f: (String) ⇒ Unit): Unit

  49. def parProcessFile(filename: String, f: (String) ⇒ Unit): Unit

  50. def parProcessFileInChunks(iterator: Iterator[String], f: (Seq[String]) ⇒ Unit, chunkSize: Int = _chunkSize): Unit

  51. def parProcessFileInChunks(stream: InputStream, f: (Seq[String]) ⇒ Unit): Unit

  52. def parProcessFileInChunks(file: File, f: (Seq[String]) ⇒ Unit): Unit

  53. def parProcessFileInChunks(filename: String, f: (Seq[String]) ⇒ Unit): Unit

  54. def processFile(iterator: Iterator[String], f: (String) ⇒ Unit): Unit

  55. def processFile(stream: InputStream, f: (String) ⇒ Unit): Unit

  56. def processFile(file: File, f: (String) ⇒ Unit): Unit

  57. def processFile(filename: String, f: (String) ⇒ Unit): Unit

  58. def readDoubleListFromFile(filename: String): Seq[Double]

  59. def readFileContents(file: File): String

  60. def readFileContents(filename: String): String

  61. def readIntegerListFromFile(filename: String, dict: Dictionary = null): Seq[Int]

    The file is assumed to be a series of lines, one string per line.

    The file is assumed to be a series of lines, one string per line. If the provided dictionary is null, we parse the string to an integer before adding it to a list. Otherwise, we look up the string in the dictionary to convert the string to an integer.

  62. def readIntegerSetFromFile(filename: String, dict: Dictionary = null): Set[Int]

    The file is assumed to be a series of lines, one string per line.

    The file is assumed to be a series of lines, one string per line. If the provided dictionary is null, we parse the string to an integer before adding it to a set. Otherwise, we look up the string in the dictionary to convert the string to an integer.

  63. def readInvertedMapListFromTsvFile(filename: String, logFrequency: Int = 1): Map[String, Seq[String]]

  64. def readLinesFromBZ2File(filename: String): Seq[String]

  65. def readLinesFromFile(file: File): Seq[String]

  66. def readLinesFromFile(filename: String): Seq[String]

  67. def readMapFromTsvFile(filename: String, skipErrors: Boolean = false): Map[String, String]

  68. def readMapListFromTsvFile(filename: String, keyIndex: Int = 0, overwrite: Boolean = false, filter: LineFilter = null): Map[String, Seq[String]]

    Reads a tab-separated file and puts the contents into a map.

    Reads a tab-separated file and puts the contents into a map.

    We give a few options: - You can set the index for the key to the map. If the key is not zero, we only add the first column as a value to this map (and so setting overwrite to true in this case doesn't make a whole lot of sense - just use readMapFromTsv instead). - If overwrite is true, we don't bother checking to see if the key is already in the map. This will speed up the processing if you know that your file only has one line per unique key. - You can provide a LineFilter object that wlil be called with each line to determine if it should be skipped.

  69. def readStringPairsFromFile(filename: String): Seq[(String, String)]

  70. def recursiveListFiles(f: File, r: Regex): Seq[File]

  71. def returnTriple(i: Int, j: Int, k: Int): (Int, Int, Int)

  72. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  73. def toString(): String

    Definition Classes
    AnyRef → Any
  74. def touchFile(filename: String): Unit

  75. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  76. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  77. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  78. def writeContentsToFile(filename: String, contents: String, append: Boolean = false): Unit

  79. def writeLinesToFile(filename: String, lines: Iterable[String], append: Boolean = false): Unit

Inherited from AnyRef

Inherited from Any

Ungrouped