Source:
<code>public void replaceAll() throws Exception { Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put("file", file); DataStore store = DataStoreFinder.getDataStore(params); final SimpleFeatureType type = store.getSchema("locations"); final FeatureWriter<SimpleFeatureType, SimpleFeature> writer; SimpleFeature f; DefaultFeatureCollection collection = new DefaultFeatureCollection(); GeometryFactory gf = JTSFactoryFinder.getGeometryFactory(); Point portland = gf.createPoint(new Coordinate( 45.52, -122.681944)); f = SimpleFeatureBuilder.build(type, new Object[] { portland, "Portland", 800, 2014 }, "locations.1"); collection.add(f); writer = store.getFeatureWriter("locations", Transaction.AUTO_COMMIT); try { while (writer.hasNext()) { writer.next(); writer.remove(); } SimpleFeatureIterator iterator = collection.features(); while (iterator.hasNext()) { SimpleFeature feature = iterator.next(); SimpleFeature newFeature = writer.next(); newFeature.setAttributes(feature.getAttributes()); writer.write(); } } finally { writer.close(); } SimpleFeatureStore featureStore = (SimpleFeatureStore) store.getFeatureSource("locations"); assertEquals("featureStore should only have the one feature we created", 1, featureStore.getFeatures().size()); String contents; if (isWindows() == true) { contents = "LAT,LON,CITY,NUMBER,YEAR\r\nPOINT (45.52 -122.681944),Portland,800,2014,"; } else { contents = "LAT,LON,CITY,NUMBER,YEAR\nPOINT (45.52 -122.681944),Portland,800,2014,"; <START> } <END> assertEquals("Ensure the file has only the one feature we created", contents.trim(), checkFileContents(file).trim()); }</code><technical_language>isWindows() String contents = "LAT,LON,CITY,NUMBER,YEAR"+System.getProperty("line.separator")"+"POINT (45.52 -122.681944),Portland,800,2014,";</technical_language>

Target:
public void replaceAll() throws Exception { Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put("file", file); DataStore store = DataStoreFinder.getDataStore(params); final SimpleFeatureType type = store.getSchema("locations"); final FeatureWriter<SimpleFeatureType, SimpleFeature> writer; SimpleFeature f; DefaultFeatureCollection collection = new DefaultFeatureCollection(); GeometryFactory gf = JTSFactoryFinder.getGeometryFactory(); Point portland = gf.createPoint(new Coordinate( 45.52, -122.681944)); f = SimpleFeatureBuilder.build(type, new Object[] { portland, "Portland", 800, 2014 }, "locations.1"); collection.add(f); writer = store.getFeatureWriter("locations", Transaction.AUTO_COMMIT); try { while (writer.hasNext()) { writer.next(); writer.remove(); } SimpleFeatureIterator iterator = collection.features(); while (iterator.hasNext()) { SimpleFeature feature = iterator.next(); SimpleFeature newFeature = writer.next(); newFeature.setAttributes(feature.getAttributes()); writer.write(); } } finally { writer.close(); } SimpleFeatureStore featureStore = (SimpleFeatureStore) store.getFeatureSource("locations"); assertEquals("featureStore should only have the one feature we created", 1, featureStore.getFeatures().size()); final String newline = System.lineSeparator(); String contents = "LAT,LON,CITY,NUMBER,YEAR" + newline + "POINT (45.52 -122.681944),Portland,800,2014,"; assertEquals("Ensure the file has only the one feature we created", contents.trim(), checkFileContents(file).trim()); }