Various code fixes (#3704)
Correctly close streams. Avoid ArithmeticException in case of /0.
This commit is contained in:
@@ -102,18 +102,15 @@ final class MinecraftItemCSVExporter implements Exporter
|
||||
|
||||
final File file = new File( this.exportDirectory, ITEM_CSV_FILE_NAME );
|
||||
|
||||
try
|
||||
try( final Writer writer = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( file ), Charset.forName( "UTF-8" ) ) ) )
|
||||
{
|
||||
FileUtils.forceMkdir( this.exportDirectory );
|
||||
|
||||
final Writer writer = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( file ), Charset.forName( "UTF-8" ) ) );
|
||||
|
||||
final String header = this.mode == ExportMode.MINIMAL ? MINIMAL_HEADER : VERBOSE_HEADER;
|
||||
writer.write( header );
|
||||
writer.write( "\n" );
|
||||
writer.write( joined );
|
||||
writer.flush();
|
||||
writer.close();
|
||||
|
||||
AELog.info( EXPORT_SUCCESSFUL_MESSAGE, lines.size(), ITEM_CSV_FILE_NAME );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user