tb.add( "name", String.class );
tb.add( "description", String.class );
tb.add( "geometry", Geometry.class );
GeometryFactory gf = new GeometryFactory();
SimpleFeatureBuilder sb = new SimpleFeatureBuilder( tb.buildFeatureType() );
ArrayList features = new ArrayList();
sb.add( "one" );
sb.add( "the first feature");
sb.add( gf.createPoint( new Coordinate(1, 1) ) ) ;
features.add( sb.buildFeature("1"));
sb.add( "two" );
sb.add( "the second feature");
sb.add( gf.createPoint( new Coordinate(2, 2) ) ) ;
features.add( sb.buildFeature("2"));
sb = new SimpleFeatureBuilder(DocumentTypeBinding.FeatureType);
sb.set( "Feature", features );
SimpleFeature f = sb.buildFeature("kml");
Encoder encoder = new Encoder(new KMLConfiguration());
encoder.setIndenting(true);
ByteArrayOutputStream out = new ByteArrayOutputStream();
encoder.encode(f, KML.kml, out );