package org.apache.poi.xssf.streaming;
import java.io.BufferedWriter;
+import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
* this class only writes the "sheetData" document fragment
* so that it was renamed to "SheetDataWriter"
*/
-public class SheetDataWriter {
+public class SheetDataWriter implements Closeable {
private static final POILogger logger = POILogFactory.getLogger(SheetDataWriter.class);
private final File _fd;
* This method <em>must</em> be invoked before calling {@link #getWorksheetXMLInputStream()}
*/
public void close() throws IOException {
- flush();
- _out.close();
- }
-
- protected void flush() throws IOException {
_out.flush();
+ _out.close();
}
protected File getTempFile() {
SheetDataWriter writer = new SheetDataWriter();
try {
writer.outputQuotedString(unicodeSurrogates);
- writer.flush();
+ writer.close();
File file = writer.getTempFile();
FileInputStream is = new FileInputStream(file);
String text;
}
assertEquals(unicodeSurrogates, text);
} finally {
- writer.close();
+ IOUtils.closeQuietly(writer);
}
}
}