You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "David Bild (JIRA)" <ji...@apache.org> on 2012/10/11 04:15:02 UTC

[jira] [Created] (IO-349) Add array offset and length argument to FileUtils.writeByteArrayToFile

David Bild created IO-349:
-----------------------------

             Summary: Add array offset and length argument to FileUtils.writeByteArrayToFile
                 Key: IO-349
                 URL: https://issues.apache.org/jira/browse/IO-349
             Project: Commons IO
          Issue Type: Improvement
          Components: Utilities
    Affects Versions: 2.4
            Reporter: David Bild
             Fix For: 2.5


The FileUtils.writeByteArrayToFile method does not allow a subset of an array to be written to a file.  Instead, the subset must be copied to a separate array, increasing the lines of code and (for all JVMs I know about) runtime.

Sister methods that take an offset and length should be added, inline with the byte array-oriented methods in the Java standard library. 

Attached is a patch that implements FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length) and FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length, boolean append) and associated testcases in FileUtilsTestCase.java.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (IO-349) Add API with array offset and length argument to FileUtils.writeByteArrayToFile

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IO-349?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory updated IO-349:
----------------------------

    Summary: Add API with array offset and length argument to FileUtils.writeByteArrayToFile  (was: Add array offset and length argument to FileUtils.writeByteArrayToFile)
    
> Add API with array offset and length argument to FileUtils.writeByteArrayToFile
> -------------------------------------------------------------------------------
>
>                 Key: IO-349
>                 URL: https://issues.apache.org/jira/browse/IO-349
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>    Affects Versions: 2.4
>            Reporter: David Bild
>              Labels: patch
>             Fix For: 2.5
>
>         Attachments: add_OffsetAndLengthArguments_To_FileUtils_writeByteArrayToFile.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The FileUtils.writeByteArrayToFile method does not allow a subset of an array to be written to a file.  Instead, the subset must be copied to a separate array, increasing the lines of code and (for all JVMs I know about) runtime.
> Sister methods that take an offset and length should be added, inline with the byte array-oriented methods in the Java standard library. 
> Attached is a patch that implements FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length) and FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length, boolean append) and associated testcases in FileUtilsTestCase.java.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (IO-349) Add API with array offset and length argument to FileUtils.writeByteArrayToFile

Posted by "David Bild (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483658#comment-13483658 ] 

David Bild commented on IO-349:
-------------------------------

Ah, yes indeed.  Thanks for the lesson.
                
> Add API with array offset and length argument to FileUtils.writeByteArrayToFile
> -------------------------------------------------------------------------------
>
>                 Key: IO-349
>                 URL: https://issues.apache.org/jira/browse/IO-349
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>    Affects Versions: 2.4
>            Reporter: David Bild
>              Labels: patch
>             Fix For: 2.5
>
>         Attachments: add_OffsetAndLengthArguments_To_FileUtils_writeByteArrayToFile.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The FileUtils.writeByteArrayToFile method does not allow a subset of an array to be written to a file.  Instead, the subset must be copied to a separate array, increasing the lines of code and (for all JVMs I know about) runtime.
> Sister methods that take an offset and length should be added, inline with the byte array-oriented methods in the Java standard library. 
> Attached is a patch that implements FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length) and FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length, boolean append) and associated testcases in FileUtilsTestCase.java.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (IO-349) Add API with array offset and length argument to FileUtils.writeByteArrayToFile

Posted by "David Bild (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483570#comment-13483570 ] 

David Bild commented on IO-349:
-------------------------------

Thanks much for the code review and commit.

FYI, the tests for the existing #writeByteArrayToFile methods use the platform default charset for String encoding.  Is there a reason to prefer UTF-8 (those were the only modifications I saw in the unit tests)?  If so, I can submit a patch to update the existing tests as well.

                
> Add API with array offset and length argument to FileUtils.writeByteArrayToFile
> -------------------------------------------------------------------------------
>
>                 Key: IO-349
>                 URL: https://issues.apache.org/jira/browse/IO-349
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>    Affects Versions: 2.4
>            Reporter: David Bild
>              Labels: patch
>             Fix For: 2.5
>
>         Attachments: add_OffsetAndLengthArguments_To_FileUtils_writeByteArrayToFile.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The FileUtils.writeByteArrayToFile method does not allow a subset of an array to be written to a file.  Instead, the subset must be copied to a separate array, increasing the lines of code and (for all JVMs I know about) runtime.
> Sister methods that take an offset and length should be added, inline with the byte array-oriented methods in the Java standard library. 
> Attached is a patch that implements FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length) and FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length, boolean append) and associated testcases in FileUtilsTestCase.java.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (IO-349) Add array offset and length argument to FileUtils.writeByteArrayToFile

Posted by "David Bild (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483139#comment-13483139 ] 

David Bild commented on IO-349:
-------------------------------

No comments?  Is this functionality already available and I just missed it?  Seems like a pretty simple patch to accept if not.
                
> Add array offset and length argument to FileUtils.writeByteArrayToFile
> ----------------------------------------------------------------------
>
>                 Key: IO-349
>                 URL: https://issues.apache.org/jira/browse/IO-349
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>    Affects Versions: 2.4
>            Reporter: David Bild
>              Labels: patch
>             Fix For: 2.5
>
>         Attachments: add_OffsetAndLengthArguments_To_FileUtils_writeByteArrayToFile.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The FileUtils.writeByteArrayToFile method does not allow a subset of an array to be written to a file.  Instead, the subset must be copied to a separate array, increasing the lines of code and (for all JVMs I know about) runtime.
> Sister methods that take an offset and length should be added, inline with the byte array-oriented methods in the Java standard library. 
> Attached is a patch that implements FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length) and FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length, boolean append) and associated testcases in FileUtilsTestCase.java.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (IO-349) Add API with array offset and length argument to FileUtils.writeByteArrayToFile

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483702#comment-13483702 ] 

Gary Gregory commented on IO-349:
---------------------------------

YW. Keep 'em coming. 
                
> Add API with array offset and length argument to FileUtils.writeByteArrayToFile
> -------------------------------------------------------------------------------
>
>                 Key: IO-349
>                 URL: https://issues.apache.org/jira/browse/IO-349
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>    Affects Versions: 2.4
>            Reporter: David Bild
>              Labels: patch
>             Fix For: 2.5
>
>         Attachments: add_OffsetAndLengthArguments_To_FileUtils_writeByteArrayToFile.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The FileUtils.writeByteArrayToFile method does not allow a subset of an array to be written to a file.  Instead, the subset must be copied to a separate array, increasing the lines of code and (for all JVMs I know about) runtime.
> Sister methods that take an offset and length should be added, inline with the byte array-oriented methods in the Java standard library. 
> Attached is a patch that implements FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length) and FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length, boolean append) and associated testcases in FileUtilsTestCase.java.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (IO-349) Add API with array offset and length argument to FileUtils.writeByteArrayToFile

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483632#comment-13483632 ] 

Gary Gregory commented on IO-349:
---------------------------------

The issue with the tests I changed is that these tests used hard offsets into the byte array returned by String.getBytes(). There is no guarantee that these offsets will address the expected bytes when the test is run on platforms with encodings that create byte arrays of different sizes. For example UTF-16 and UTF-32 type of encodings. This is unlikely but removing the mystery answer from getBytes() is simple.


                
> Add API with array offset and length argument to FileUtils.writeByteArrayToFile
> -------------------------------------------------------------------------------
>
>                 Key: IO-349
>                 URL: https://issues.apache.org/jira/browse/IO-349
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>    Affects Versions: 2.4
>            Reporter: David Bild
>              Labels: patch
>             Fix For: 2.5
>
>         Attachments: add_OffsetAndLengthArguments_To_FileUtils_writeByteArrayToFile.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The FileUtils.writeByteArrayToFile method does not allow a subset of an array to be written to a file.  Instead, the subset must be copied to a separate array, increasing the lines of code and (for all JVMs I know about) runtime.
> Sister methods that take an offset and length should be added, inline with the byte array-oriented methods in the Java standard library. 
> Attached is a patch that implements FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length) and FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length, boolean append) and associated testcases in FileUtilsTestCase.java.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (IO-349) Add API with array offset and length argument to FileUtils.writeByteArrayToFile

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IO-349?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory resolved IO-349.
-----------------------------

    Resolution: Fixed

It's simple unless the unit tests have subtle bugs ;)

commit -m "[IO-349] Add API with array offset and length argument to FileUtils.writeByteArrayToFile. Applied patch with changes: (1) Fixed bugs in unit tests (2) Added @since tags (3) Fixed formatting." C:/svn/org/apache/commons/trunks-proper/io/src/test/java/org/apache/commons/io/FileUtilsTestCase.java C:/svn/org/apache/commons/trunks-proper/io/src/main/java/org/apache/commons/io/FileUtils.java C:/svn/org/apache/commons/trunks-proper/io/src/changes/changes.xml C:/svn/org/apache/commons/trunks-proper/io/pom.xml
    Sending        C:/svn/org/apache/commons/trunks-proper/io/pom.xml
    Sending        C:/svn/org/apache/commons/trunks-proper/io/src/changes/changes.xml
    Sending        C:/svn/org/apache/commons/trunks-proper/io/src/main/java/org/apache/commons/io/FileUtils.java
    Sending        C:/svn/org/apache/commons/trunks-proper/io/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
    Transmitting file data ...
    Committed revision 1401648.
                
> Add API with array offset and length argument to FileUtils.writeByteArrayToFile
> -------------------------------------------------------------------------------
>
>                 Key: IO-349
>                 URL: https://issues.apache.org/jira/browse/IO-349
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>    Affects Versions: 2.4
>            Reporter: David Bild
>              Labels: patch
>             Fix For: 2.5
>
>         Attachments: add_OffsetAndLengthArguments_To_FileUtils_writeByteArrayToFile.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The FileUtils.writeByteArrayToFile method does not allow a subset of an array to be written to a file.  Instead, the subset must be copied to a separate array, increasing the lines of code and (for all JVMs I know about) runtime.
> Sister methods that take an offset and length should be added, inline with the byte array-oriented methods in the Java standard library. 
> Attached is a patch that implements FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length) and FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length, boolean append) and associated testcases in FileUtilsTestCase.java.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (IO-349) Add array offset and length argument to FileUtils.writeByteArrayToFile

Posted by "David Bild (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IO-349?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Bild updated IO-349:
--------------------------

    Attachment: add_OffsetAndLengthArguments_To_FileUtils_writeByteArrayToFile.patch
    
> Add array offset and length argument to FileUtils.writeByteArrayToFile
> ----------------------------------------------------------------------
>
>                 Key: IO-349
>                 URL: https://issues.apache.org/jira/browse/IO-349
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>    Affects Versions: 2.4
>            Reporter: David Bild
>              Labels: patch
>             Fix For: 2.5
>
>         Attachments: add_OffsetAndLengthArguments_To_FileUtils_writeByteArrayToFile.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The FileUtils.writeByteArrayToFile method does not allow a subset of an array to be written to a file.  Instead, the subset must be copied to a separate array, increasing the lines of code and (for all JVMs I know about) runtime.
> Sister methods that take an offset and length should be added, inline with the byte array-oriented methods in the Java standard library. 
> Attached is a patch that implements FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length) and FileUtils.writeByteArrayToFile(File file, byte[] data, int offset, int length, boolean append) and associated testcases in FileUtilsTestCase.java.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira