On 6 March 2018 at 23:22, Gary Gregory <garydgreg...@gmail.com> wrote:
> On Tue, Mar 6, 2018 at 4:13 PM, sebb <seb...@gmail.com> wrote:
>
>> On 6 March 2018 at 21:38, Gary Gregory <garydgreg...@gmail.com> wrote:
>> > Hi All:
>> >
>> > Any objection to adding:
>> >
>> > /**
>> >  * Reads n lines from this reader.
>> >  */
>> > List<String>
>> > org.apache.commons.io.input.ReversedLinesFileReader.readLine(long
>> lineCount)
>> >
>> > ?
>>
>> Yes.
>>
>> The name makes it sound like it is reading a single line, yet the
>> output is a list of lines.
>>
>
> Cut and paste error, obviously, the method should be called "readLines(long
> lineCount)"
>
>
>> Also, this seems like the sort of function that could be dealt with
>> via a more general approach which would work with any method.
>> AFAICT there would be no gain in embedding the looping code in IO
>> rather than having it somewhere else.
>>
>
> The gain is that your questions below would be defined by the new method.

As they would by an independent method.

>
>> What happens if there aren't enough lines in the file?
>>
>
> If you ask for 30 lines, and there are only 10 lines, you get 10 lines. I'm
> not sure what else could happen, you can't invent data that does not exist.
>
> What happens if there is an IO error reading one of the lines?
>>
>
> Then the method throws an exception, just like readLine() does.

So all the lines that have already been read are lost?

> Would you
> ask this question of readLine(): What happens if reading a single character
> or a buffer of character causes an IO error?
>
> Gary
>
>
>>
>> > Gary
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
>> For additional commands, e-mail: dev-h...@commons.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to