### Question:
ShapefileGeometryCursor extends GeometryCursor { @Override public Geometry next() { if (! hasNext()) { return null; } try { recordNumber = inputStream.readInt(); int recLength = inputStream.readInt(); position += 8; int recordSizeBytes = (recLength * 2); byte[] bytes = new byte[recordSizeBytes]; int read = inputStream.read(bytes); Geometry polyline = importFromESRIShape.execute(0, geomType, ByteBuffer.wrap(bytes)); position += recordSizeBytes; return polyline; } catch (IOException e) { e.printStackTrace(); } return null; } ShapefileGeometryCursor(File inFile);  ShapefileGeometryCursor(InputStream in); @Override Geometry next(); @Override int getGeometryID(); Envelope2D getEnvelope2D(); boolean hasNext(); Geometry.Type getGeometryType();  }### Answer:
@Test public void spatialOpsWithShapefileAsGeometryCursor() throws IOException { { File file = getTestShapefile("polygons"); ShapefileGeometryCursor polygonShapefileCursor = new ShapefileGeometryCursor(file); GeometryCursor unionCursor = OperatorUnion.local().execute(polygonShapefileCursor, null, null); Geometry dissolvedGeometry = unionCursor.next(); Polygon multiPoly = (Polygon) dissolvedGeometry; assertTrue(multiPoly.getExteriorRingCount() == 4); assertTrue(unionCursor.next() == null); } { File file = getTestShapefile("polylines"); ShapefileGeometryCursor polylineShapefileCursor = new ShapefileGeometryCursor(file); GeometryCursor bufferCursor = OperatorBuffer.local().execute(polylineShapefileCursor, null, new double[]{0.5}, true, null); Polygon polygon = (Polygon) bufferCursor.next(); assertTrue(bufferCursor.next() == null); assertTrue(polygon.getExteriorRingCount() == 3); } }