private void deleteEmptyFileOnException ( OutputStream outputStream , String path ) { try { outputStream . close ( ) ; File fileToDelete = new File ( path ) ; fileToDelete . delete ( ) ; } catch ( Exception e ) { // Best effort delete. } }
Helper to delete an empty file in the case of an exception