commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (IO-349) Add API with array offset and length argument to FileUtils.writeByteArrayToFile
Date Wed, 24 Oct 2012 21:54:12 GMT

    [ 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

Mime
View raw message