Skip to content

Instantly share code, notes, and snippets.

@ques0942
Created November 24, 2016 12:07
Show Gist options
  • Save ques0942/813940d73b854dd7ed65eb7b4a992e01 to your computer and use it in GitHub Desktop.
Save ques0942/813940d73b854dd7ed65eb7b4a992e01 to your computer and use it in GitHub Desktop.
(Java)serializeされるときのバイトサイズを計算する ref: http://qiita.com/ques0942/items/6452c09c34e0b34b8eb2
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(target);
oos.flush();
oos.close();
baos.toByteArray().length // ここで取得される値がバイトサイズ
SerializationUtils.serialize((Serializable) target).length // ここで取得される値がバイトサイズ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment