DBaseFileWriter implements AutoCloseable { public void write(AttributeProvider... providers) throws IOException, AttributeException { writeHeader(providers); for (final AttributeProvider provider : providers) { writeRecord(provider); } close(); } @SuppressWarnings("resource")  DBaseFileWriter(File stream);  DBaseFileWriter(URL stream);  DBaseFileWriter(WritableByteChannel channel);  DBaseFileWriter(OutputStream dbfStream); DBaseCodePage getCodePage(); void setCodePage(DBaseCodePage code); @Pure static boolean isSupportedType(DBaseFieldType type); void writeHeader(AttributeProvider... providers); void writeHeader(List<? extends AttributeProvider> providers); @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:magicnumber"}) void writeRecord(AttributeProvider element); void write(AttributeProvider... providers); void write(List<? extends AttributeProvider> providers); @Override @SuppressWarnings("checkstyle:magicnumber") void close();  }
@Test public void testWrite() throws Exception { assertTestingInputStream(this.list); File tmpFile = File.createTempFile("dbfwriter", ".dbf"); tmpFile.deleteOnExit(); try { DBaseFileWriter writer = new DBaseFileWriter(tmpFile); writer.write(ArrayUtil.toArray(this.list, AttributeProvider.class)); writer.close(); List<AttributeProvider> newContent = readFile(new FileInputStream(tmpFile)); boolean found; for(AttributeProvider provider : this.list) { found = false; for(AttributeProvider provider2 : newContent) { if (sameProvider(provider,provider2)) { newContent.remove(provider2); found = true; break; } } if (!found) fail("some data was not correctly written"); } if (!newContent.isEmpty()) fail("the written content has more data than the source"); } finally { tmpFile.delete(); } }