diff --git a/scripted/FilteredLoader.scala b/scripted/FilteredLoader.scala new file mode 100644 index 000000000..983edf040 --- /dev/null +++ b/scripted/FilteredLoader.scala @@ -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 +} \ No newline at end of file diff --git a/util/io/FileUtilities.scala b/util/io/FileUtilities.scala index be115bda8..06034befd 100644 --- a/util/io/FileUtilities.scala +++ b/util/io/FileUtilities.scala @@ -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)