What type is the best to manage binary data in Java? -
i'm getting documents web , many of them binary files (executables, pdf, etc.). in java, correct type hold binary data until save in database? can use string this?
use byte array (byte[]) or inputstream (e.g. bytearrayinputstream). java strings not container generic binary data.
the apache library commons-io has nice utility classes dealing bytes , streams.
e.g. ioutils.tobytearray(inputstream)
bytebuffer introduced part of java nio, available in java 4 (1.4) , later. in specialized scenarios, can have performance benefits on using byte[]. has helpful convenience methods. still use byte[], though, since more known, more common in apis, , performs enough.
Comments
Post a Comment