Code example for ObjectOutputStream

Methods: close, flush, writeObject

0
 
	public void sendResponse(Socket outgoingSocket, DataPacket<?> dataPacket)
	{ 
		 
		try{ 
			outStream = new ObjectOutputStream(outgoingSocket.getOutputStream());
			outStream.writeObject(dataPacket);
			outStream.flush();
		} 
		catch(IOException ioe)
		{ 
			logger.error("Exception occurred in sending response in AbstractEventListener", ioe);
		} 
		finally{ 
			 
			closeStream(); 
		} 
	} 
	 
	private void closeStream() 
	{ 
		try { 
			outStream.close();
		} catch (IOException e) {
			logger.error("Exception occurred in closing the stream in AbstractEventListener", e);
		} 
	} 
}