1 2 /* 3 * Hunt - A refined core library for D programming language. 4 * 5 * Copyright (C) 2018-2019 HuntLabs 6 * 7 * Website: https://www.huntlabs.net/ 8 * 9 * Licensed under the Apache-2.0 License. 10 * 11 */ 12 13 module hunt.io.ObjectOutput; 14 15 /** 16 * ObjectOutput extends the DataOutput interface to include writing of objects. 17 * DataOutput includes methods for output of primitive types, ObjectOutput 18 * extends that interface to include objects, arrays, and Strings. 19 * 20 * @author unascribed 21 * @see java.io.InputStream 22 * @see java.io.ObjectOutputStream 23 * @see java.io.ObjectInputStream 24 * @since 1.1 25 */ 26 import hunt.io.DataOutput; 27 import hunt.util.Common; 28 29 public interface ObjectOutput : DataOutput, AutoCloseable { 30 /** 31 * Write an object to the underlying storage or stream. The 32 * class that implements this interface defines how the object is 33 * written. 34 * 35 * @param obj the object to be written 36 * @exception IOException Any of the usual Input/Output related exceptions. 37 */ 38 public void writeObject(Object obj) 39 ; 40 41 /** 42 * Writes a byte. This method will block until the byte is actually 43 * written. 44 * @param b the byte 45 * @exception IOException If an I/O error has occurred. 46 */ 47 public void write(int b) ; 48 49 /** 50 * Writes an array of bytes. This method will block until the bytes 51 * are actually written. 52 * @param b the data to be written 53 * @exception IOException If an I/O error has occurred. 54 */ 55 public void write(byte[] b) ; 56 57 /** 58 * Writes a sub array of bytes. 59 * @param b the data to be written 60 * @param off the start offset in the data 61 * @param len the number of bytes that are written 62 * @exception IOException If an I/O error has occurred. 63 */ 64 public void write(byte[] b, int off, int len) ; 65 66 /** 67 * Flushes the stream. This will write any buffered 68 * output bytes. 69 * @exception IOException If an I/O error has occurred. 70 */ 71 public void flush() ; 72 73 /** 74 * Closes the stream. This method must be called 75 * to release any resources associated with the 76 * stream. 77 * @exception IOException If an I/O error has occurred. 78 */ 79 public void close() ; 80 }