you need to serialize a class as an array of bytes without "built-in serialization api" i.e. , as I understand it, do not use wrappers for library input-output streams, but write your own. I can not understand where to dig and what approximate algorithm of actions for this implementation? here is my implementation

public static byte[] documentToByte(Document document) throws TransformerException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); StreamResult result = new StreamResult(bos); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); DOMSource source = new DOMSource(document); transformer.transform(source, result); byte[] data = bos.toByteArray(); return data; } 
  • one
    Judging by the task, you do not need a stream, but a serializer. Serialize to a stream, and use an instance of ByteArrayOutputStream as the stream. - Mark Shevchenko
  • @Devoli, comments are poorly suited for code, transfer it to your question ( править button) - gil9red
  • @Devoli In this code, serialization api is a Transformer . Seems to want you to write your Transformer . - Mark Shevchenko
  • one
    First you need to deserialize and then change the serializer. - Roman C
  • @MarkShevchenko can tell how you would implement it? - Devoli 2:32 pm

0