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

Gary D. Gregory commented on IO-574:
------------------------------------

Answering my question from above: Possibly in 
{{{}org.apache.commons.io.output.ProxyOutputStream{}}}.

> Add Writes of Primitive Values To OutputStream
> ----------------------------------------------
>
>                 Key: IO-574
>                 URL: https://issues.apache.org/jira/browse/IO-574
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Utilities
>    Affects Versions: 2.6
>            Reporter: David Mollitor
>            Priority: Major
>
> Add the capability to serialize Java primitives to OutputStream classes.
>  
> {code:java}
> public static void writeInt(OutputStream out, int v) throws IOException {
>   out.write((byte) (0xff & (v >> 24)));
>   out.write((byte) (0xff & (v >> 16)));
>   out.write((byte) (0xff & (v >> 8)));
>   out.write((byte) (0xff & v));
> }{code}
>  
> [https://github.com/apache/hbase/blob/c3b4f788b16ac4e0e8cfd319f495308ba4d158f5/hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/StreamUtils.java#L215-L243]
> [https://stackoverflow.com/questions/6374915/java-convert-int-to-byte-array-of-4-bytes]
>  
> Could also create a Serialize object that has an internal buffer that the 
> bytes are written to before calling {{out.write(buf)}} once.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to