more uniform Bytes.read_stream vs. File.read_stream;
authorwenzelm
Tue, 02 Jul 2024 23:28:55 +0200
changeset 80481 0e2b09fef3d2
parent 80480 972f7a4cdc0e
child 80482 2136ecf06a4c
more uniform Bytes.read_stream vs. File.read_stream;
src/Pure/General/file.scala
--- a/src/Pure/General/file.scala	Tue Jul 02 23:13:35 2024 +0200
+++ b/src/Pure/General/file.scala	Tue Jul 02 23:28:55 2024 +0200
@@ -204,16 +204,7 @@
   def read(file: JFile): String = Bytes.read(file).text
   def read(path: Path): String = read(path.file)
 
-
-  def read_stream(reader: BufferedReader): String =
-    Library.string_builder(hint = 100) { output =>
-      var c = -1
-      while ({ c = reader.read; c != -1 }) output += c.toChar
-      reader.close()
-    }
-
-  def read_stream(stream: InputStream): String =
-    read_stream(new BufferedReader(new InputStreamReader(stream, UTF8.charset)))
+  def read_stream(stream: InputStream): String = Bytes.read_stream(stream).text
 
   def read_gzip(file: JFile): String =
     read_stream(new GZIPInputStream(new BufferedInputStream(new FileInputStream(file))))