Java. Serialization an array -
lets supose define class
public class pointfloat { float x; float y; } then instantiate array
pointfloat[] points = new pointfloat[10]; at point have array of ten pointfloat objects. lets supose code assigns values x , y every pointfloats. need store array in varbinary in mysql database.
to accomplish need convert array of pointfloats byte[] can insert database using preparedstatement nothing new me use preparedstatement first time using objects serialization.
how convert array of pointfloat of size byte[]?. please keep simple possible.
thank reading.
you can use objectoutputstream write array bytearrayoutputstream. see answer details , example: https://stackoverflow.com/a/2836659/337621
since object contains 2 floats, standard serialization fits needs.
Comments
Post a Comment