[jira] [Commented] (GROOVY-8467) IOGroovyMethods class readLine method works unexpected in

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (GROOVY-8467) IOGroovyMethods class readLine method works unexpected in

JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/GROOVY-8467?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16357877#comment-16357877 ]

Paul King commented on GROOVY-8467:
-----------------------------------

There isn't really a way to fix it, so it would just be a matter of deprecating it or throwing an exception if it was ever used with a Reader not supporting {{mark()}. But if someone does have such a reader and know what they are doing, it is still useful functionality.

> IOGroovyMethods class readLine method works unexpected in  
> -----------------------------------------------------------
>
>                 Key: GROOVY-8467
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8467
>             Project: Groovy
>          Issue Type: Bug
>         Environment: windows 7
>            Reporter: zhuxiaobing
>            Priority: Major
>         Attachments: Screenshot from 2018-02-05 13-30-03.png, groovy_test_linux.zip, groovy_test_win.zip
>
>
> i have a android aapt dump file
> i try to read the file use the code below:
>  
> {code:java}
> InputStreamReader inputReader = new InputStreamReader(dumpFile)
> String line = null
> while ((line = inputReader.readLine()) != null){
>     println(line)
> }
> {code}
> the dumpfile uses \r\n to start a new line, while the IOGroovyMethods
> readLineFromReaderWithoutMark method which called by readLine  method  is : 
> {code:java}
>  private static String readLineFromReaderWithoutMark(Reader input) throws IOException {
>     int c = input.read();
>     if(c == -1) {
>         return null;
>     } else {
>         StringBuilder line;
>         for(line = new StringBuilder(expectedLineLength); c != EOF && c != 10 && c != 13; c = input.read()) {
>             char ch = (char)c;
>             line.append(ch);
>         }
>         return line.toString();
>     }
> }{code}
>  this casues an extra empty line read.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)