Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public File create( final String name, final InputStream inputStream ) throws IO
final File file;
if( directory.exists() && directory.isDirectory() ) file = File.createTempFile( name, ".tmp", directory );
else file = File.createTempFile( name, ".tmp" );
try( FileOutputStream fos = new FileOutputStream( file)) {
inputStream.transferTo(fos);
try( FileOutputStream fos = new FileOutputStream( file )) {
inputStream.transferTo( fos );
}
if( FILES.get() == null ) FILES.set( new ArrayList<>() );
FILES.get().add( file );
Expand All @@ -44,7 +44,7 @@ public File create( final InputStream inputStream ) throws IOException {
public void delete( final File file ) throws IOException {
if( FILES.get() == null ) return;
final Optional<File> result = FILES.get().stream()
.filter( target -> target.getAbsolutePath().equals( file.getAbsolutePath() ) )
.filter( target -> target.getAbsolutePath().equals( file.getAbsolutePath() ))
.findFirst();
if( result.isPresent() ){
final File target = result.get();
Expand All @@ -55,9 +55,8 @@ public void delete( final File file ) throws IOException {

@Override
public void cleanUp() throws IOException {
for( final File file : FILES.get() ){
if( file.exists() ) Files.delete( file.toPath() );
}
if( FILES.get() == null ) return;
for( final File file : FILES.get() ) if( file.exists() ) Files.delete( file.toPath() );
FILES.remove();
}
}