added plain read_file;
authorwenzelm
Tue, 22 Dec 2009 17:13:43 +0100
changeset 34162 610ec1e0c848
parent 34161 4c845a8f1357
child 34163 69b7e50656c3
added plain read_file;
src/Pure/System/isabelle_system.scala
--- a/src/Pure/System/isabelle_system.scala	Tue Dec 22 17:13:18 2009 +0100
+++ b/src/Pure/System/isabelle_system.scala	Tue Dec 22 17:13:43 2009 +0100
@@ -8,7 +8,8 @@
 
 import java.util.regex.Pattern
 import java.util.Locale
-import java.io.{BufferedInputStream, FileInputStream, File, IOException}
+import java.io.{BufferedInputStream, FileInputStream, BufferedReader, InputStreamReader,
+  File, IOException}
 import java.awt.{GraphicsEnvironment, Font}
 
 import scala.io.Source
@@ -43,6 +44,21 @@
     val rc = proc.waitFor
     (output, rc)
   }
+
+
+  /* platform files */
+
+  def read_file(file: File): String =
+  {
+    val buf = new StringBuilder(file.length.toInt)
+    val reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charset))
+    var c = reader.read
+    while (c != -1) {
+      buf.append(c.toChar)
+      c = reader.read
+    }
+    buf.toString
+  }
 }