mirror of https://github.com/sbt/sbt.git
A basic readLines method and moving the filtered class loader
This commit is contained in:
parent
a872ebc5e5
commit
dfb7397b8a
|
|
@ -0,0 +1,18 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2009 Mark Harrah
|
||||
*/
|
||||
package xsbt.test
|
||||
|
||||
final class FilteredLoader(parent: ClassLoader) extends ClassLoader(parent) with NotNull
|
||||
{
|
||||
@throws(classOf[ClassNotFoundException])
|
||||
override final def loadClass(className: String, resolve: Boolean): Class[_] =
|
||||
{
|
||||
if(className.startsWith("java.") || className.startsWith("javax."))
|
||||
super.loadClass(className, resolve)
|
||||
else
|
||||
throw new ClassNotFoundException(className)
|
||||
}
|
||||
override def getResources(name: String) = null
|
||||
override def getResource(name: String) = null
|
||||
}
|
||||
|
|
@ -380,6 +380,20 @@ object FileUtilities
|
|||
out.toByteArray
|
||||
}
|
||||
|
||||
// Not optimized for large files
|
||||
def readLines(file: File): List[String] = readLines(file, defaultCharset)
|
||||
def readLines(file: File, charset: Charset): List[String] =
|
||||
{
|
||||
fileReader(charset)(file){ in =>
|
||||
def readLine(accum: List[String]): List[String] =
|
||||
{
|
||||
val line = in.readLine()
|
||||
if(line eq null) accum.reverse else readLine(line :: accum)
|
||||
}
|
||||
readLine(Nil)
|
||||
}
|
||||
}
|
||||
|
||||
/** A pattern used to split a String by path separator characters.*/
|
||||
private val PathSeparatorPattern = java.util.regex.Pattern.compile(File.pathSeparator)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue