Scala Programming Language
  1. Scala Programming Language
  2. SI-6592

Unexpected result of scala.io.Source.fromFile(...).mkString(",") evaluation

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Misc Library
    • Labels:
    • Environment:

      scala 2.9.2, java 1.6.0_24, Ubuntu 11.10

      Description

      I've 2 files that have only one difference - "\r\n" sequence in the test.txt
      [vladimir@vladimir tmp]$ cat test.txt
      line1
      line2
      line3
      [vladimir@vladimir tmp]$ cat test2.txt
      line1
      line2
      line3[vladimir@vladimir tmp]$

      I try to execute in the REPL:

      scala> scala.io.Source.fromFile("/tmp/test.txt").mkString(",")
      res17: String =
      ,l,i,n,e,1,
      ,l,i,n,e,2,
      ,l,i,n,e,3,
      "

      scala> scala.io.Source.fromFile("/tmp/test2.txt").mkString(",")
      res18: String =
      ,,i,n,e,1,
      ,l,i,n,e,2,
      ,l,i,n,e,3

      scala>

      As you can see, for test2.txt file the first "l" character ommited. I think, that it isn't expected behaviour.

      1. test.txt
        0.0 kB
        Vladimir Kuptsov
      2. test2.txt
        0.0 kB
        Vladimir Kuptsov

        Activity

        Hide
        Alexei Tereschenko added a comment - - edited

        If I run the following code from an IDE, not from REPL:

         
        object Test {
          def main(args: Array[String]) = {
            println(scala.io.Source.fromFile("/tmp/test.txt").mkString(","))
            println(scala.io.Source.fromFile("/tmp/test2.txt").mkString(","))
          }
        }
        

        then I receive the following output:

        ,
        ,
        ,l,i,n,e,3
        ,
        ,
        ,

        Show
        Alexei Tereschenko added a comment - - edited If I run the following code from an IDE, not from REPL: object Test { def main(args: Array[String]) = { println(scala.io.Source.fromFile("/tmp/test.txt").mkString(",")) println(scala.io.Source.fromFile("/tmp/test2.txt").mkString(",")) } } then I receive the following output: , , ,l,i,n,e,3 , , ,
        Hide
        James Iry added a comment -

        2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.

        Show
        James Iry added a comment - 2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.
        Hide
        James Iry added a comment -

        2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.

        Show
        James Iry added a comment - 2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.

          People

          • Assignee:
            Unassigned
            Reporter:
            Vladimir Kuptsov
          • Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:

              Development