[ https://issues.apache.org/jira/browse/IO-574?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16434560#comment-16434560 ]
Gary Gregory commented on IO-574: --------------------------------- Note: We have this kind of code in {{org.apache.commons.io.EndianUtils}}. Where would we put this? It seems like we need an Endian enum class with BIG, MIDDLE, and LITTLE and implementation of read and write methods... > 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: BELUGA BEHR > 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 (v7.6.3#76005)