{ baos = new ByteArrayOutputStream( ); dos = new DataOutputStream( baos ); for ( int j = 0; j < columnCount; j++ ) { Object fieldValue = null; try { fieldValue = resultObjects[i].getFieldValue( j + 1 ); } catch ( DataException e ) {  }   if ( fieldValue == null ) { dos.writeByte( 0 ); continue; } else { dos.writeByte( 1 ); }  Class fieldType = typeArray[j]; if ( fieldType.equals( Integer.class ) ) dos.writeInt( ( (Integer) fieldValue ).intValue( ) ); else if ( fieldType.equals( Double.class ) ) dos.writeDouble( ( (Double) fieldValue ).doubleValue( ) ); else if ( fieldType.equals( BigDecimal.class ) ) dos.writeUTF( ( (BigDecimal) fieldValue ).toString( ) ); else if ( fieldType.equals( Date.class ) ) dos.writeLong( ( (Date) fieldValue ).getTime( ) ); else if ( fieldType.equals( Time.class ) ) dos.writeLong( ( (Time) fieldValue ).getTime( ) ); else if ( fieldType.equals( Timestamp.class ) ) dos.writeLong( ( (Timestamp) fieldValue ).getTime( ) ); else if ( fieldType.equals( Boolean.class ) ) dos.writeBoolean( ( (Boolean) fieldValue ).booleanValue( ) ); else if ( fieldType.equals( String.class ) || fieldType.equals( DataType.getClass( DataType.ANY_TYPE ) ) ) dos.writeUTF( fieldValue.toString( ) ); } dos.flush( );  rowsDataBytes = baos.toByteArray( ); IOUtil.writeInt( bos, rowsDataBytes.length ); bos.write( rowsDataBytes );  rowsDataBytes = null; dos = null; baos = null; }
writeData( bos, resultObjects[i] );
	void writeData( OutputStream bos,			IResultObject[] resultObjects, int length ) throws IOException	{		byte[] rowsDataBytes;		ByteArrayOutputStream baos;		DataOutputStream dos;				for ( int i = 0; i < length; i++ )		{			baos = new ByteArrayOutputStream( );			dos = new DataOutputStream( baos );			for ( int j = 0; j < columnCount; j++ )			{				Object fieldValue = null;				try				{					fieldValue = resultObjects[i].getFieldValue( j + 1 );				}				catch ( DataException e )				{					// never get here since the index value is always value				}									// process null object				if ( fieldValue == null )				{										dos.writeByte( 0 );					continue;				}				else				{					dos.writeByte( 1 );				}								Class fieldType = typeArray[j];				if ( fieldType.equals( Integer.class ) )					dos.writeInt( ( (Integer) fieldValue ).intValue( ) );				else if ( fieldType.equals( Double.class ) )					dos.writeDouble( ( (Double) fieldValue ).doubleValue( ) );				else if ( fieldType.equals( BigDecimal.class ) )					dos.writeUTF( ( (BigDecimal) fieldValue ).toString( ) );				else if ( fieldType.equals( Date.class ) )					dos.writeLong( ( (Date) fieldValue ).getTime( ) );				else if ( fieldType.equals( Time.class ) )					dos.writeLong( ( (Time) fieldValue ).getTime( ) );				else if ( fieldType.equals( Timestamp.class ) )					dos.writeLong( ( (Timestamp) fieldValue ).getTime( ) );				else if ( fieldType.equals( Boolean.class ) )					dos.writeBoolean( ( (Boolean) fieldValue ).booleanValue( ) );				else if ( fieldType.equals( String.class )						|| fieldType.equals( DataType.getClass( DataType.ANY_TYPE ) ) )					dos.writeUTF( fieldValue.toString( ) );			}			dos.flush( );			rowsDataBytes = baos.toByteArray( );			IOUtil.writeInt( bos, rowsDataBytes.length );			bos.write( rowsDataBytes );			rowsDataBytes = null;			dos = null;			baos = null;		}	}