Code example for Externalizable

Methods: writeExternal

0
	public static final long	WEEK		= DAY * 7; 
 
	public static byte[] toStream(Externalizable iSource) throws IOException { 
		final ByteArrayOutputStream stream = new ByteArrayOutputStream(); 
		final ObjectOutputStream oos = new ObjectOutputStream(stream); 
		iSource.writeExternal(oos); 
		oos.flush(); 
		stream.flush(); 
		return stream.toByteArray(); 
	} 
 
	public static long getTimeAsMillisecs(final Object iSize) { 
		if (iSize == null) 
			throw new IllegalArgumentException("Time is null"); 
 
		if (iSize instanceof Number) 
			// MILLISECS 
			return ((Number) iSize).longValue(); 
 
		String time = iSize.toString();