Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly specifying RNPair line terminator truncates last line #84

Open
asflierl opened this issue Apr 9, 2013 · 1 comment
Open

Comments

@asflierl
Copy link

asflierl commented Apr 9, 2013

In the following REPL session, res1 clearly is wrong, it should be equivalent to res2. This only seems to happen with RNPair. Using NewLine or CarriageReturn seems fine.

The version of scala-io I used is 0.4.2.

Welcome to Scala version 2.10.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_38).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import scalax.file.Path
import scalax.file.Path

scala> import scalax.io.Line.Terminators.RNPair
import scalax.io.Line.Terminators.RNPair

scala> val f = Path.createTempFile()
f: scalax.file.defaultfs.DefaultPath = Path(/tmp/_UBQ4rn7147447547355346080.tmp)

scala> f.writeStrings(Seq("abc","def"), RNPair sep)

scala> f.lines(RNPair).toList
res1: List[String] = List(abc, d)

scala> f.lines().toList
res2: List[String] = List(abc, def)
@rtyley
Copy link

rtyley commented Aug 26, 2017

Reproduced with current master on 2.12 branch:

scala> import Line.Terminators.Custom
scala> import java.io.StringReader

scala> val resource = Resource.fromReader(new StringReader("foo**bar**bogus"))scala> resource.string
res4: String = foo**bar**bogus

scala> // read each segment ending in ** but do not include **
     | val lines = resource.lines(terminator=Custom("**"), includeTerminator=false)
lines: scalax.io.LongTraversable[String] = LongTraversable(...)

scala> lines.toList
res6: List[String] = List(foo, bar, bog)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants