@Test public void testCloseQuietly_silentWriter() throws Exception { Writer writer = new Writer() { @Override public void write( char[] arg0, int arg1, int arg2 ) throws IOException { } @Override public void flush() throws IOException { } @Override public void close() throws IOException { throw new IOException(); } }; Utils.closeQuietly( writer ); }
public static void closeQuietly( InputStream in ) { if( in != null ) { try { in.close(); } catch( IOException e ) { } } }
Utils { public static void closeQuietly( InputStream in ) { if( in != null ) { try { in.close(); } catch( IOException e ) { } } } }
Utils { public static void closeQuietly( InputStream in ) { if( in != null ) { try { in.close(); } catch( IOException e ) { } } } private  Utils(); }
Utils { public static void closeQuietly( InputStream in ) { if( in != null ) { try { in.close(); } catch( IOException e ) { } } } private  Utils(); static boolean isEmptyOrWhitespaces( String s ); static String capitalize( String s ); static String removeFileExtension( String filename ); static List<String> splitNicely( String toSplit, String separator ); static List<String> splitNicelyWithPattern( String toSplit, String patternSeparator ); static List<String> filterEmptyValues( List<String> values ); static String format( Collection<String> items, String separator ); static String expandTemplate(String s, Properties params); static void closeQuietly( InputStream in ); static void closeQuietly( OutputStream out ); static void closeQuietly( Reader reader ); static void closeQuietly( Writer writer ); static void copyStreamUnsafelyUseWithCaution( InputStream in, OutputStream os ); static void copyStreamSafely( InputStream in, ByteArrayOutputStream os ); static void copyStream( InputStream in, File outputFile ); static void copyStream( File inputFile, File outputFile ); static void copyStream( File inputFile, OutputStream os ); static void writeStringInto( String s, File outputFile ); static void appendStringInto( String s, File outputFile ); static String readFileContent( File file ); static String readFileContentQuietly( File file, Logger logger ); static String readUrlContent( String url ); static String readUrlContentQuietly( String url, Logger logger ); static Properties readPropertiesFile( File file ); static Properties readPropertiesFileQuietly( File file, Logger logger ); static Properties readPropertiesQuietly( String fileContent, Logger logger ); static void writePropertiesFile( Properties properties, File file ); static String cleanNameWithAccents( String name ); static void createDirectory( File directory ); static List<File> listAllFiles( File directory ); static String updateProperties( String propertiesContent, Map<String,String> keyToNewValue ); static List<File> listAllFiles( File directory, String fileExtension ); static List<File> listAllFiles( File directory, boolean includeDirectories ); static List<File> listDirectFiles( File directory, String fileExtension ); static List<File> listDirectories( File root ); static Map<String,byte[]> storeDirectoryResourcesAsBytes( File directory ); static Map<String,byte[]> storeDirectoryResourcesAsBytes( File directory, List<String> exclusionPatteners ); static Map<String,String> storeDirectoryResourcesAsString( File directory ); static String computeFileRelativeLocation( File rootDirectory, File subFile ); static void extractZipArchive( File zipFile, File targetDirectory ); static void extractZipArchive( File zipFile, File targetDirectory, String entryPattern, String removedEntryPrefix ); static boolean isAncestor( File ancestorCandidate, File file ); static void deleteFilesRecursively( File... files ); static void deleteFilesRecursivelyAndQuietly( File... files ); static String writeExceptionButDoNotUseItForLogging( Throwable t ); static void logException( Logger logger, Level logLevel, Throwable t, String message ); static void logException( Logger logger, Level logLevel, Throwable t ); static void logException( Logger logger, Throwable t ); static void closeStatement( PreparedStatement ps, Logger logger ); static void closeStatement( Statement st, Logger logger ); static void closeResultSet( ResultSet resultSet, Logger logger ); static void closeConnection( Connection conn, Logger logger ); static boolean isAncestorFile( File potentialAncestor, File file ); static void copyDirectory( File source, File target ); static Map.Entry<String,Integer> findUrlAndPort( String url ); static String getValue(Map<String,String> map, String key, String defaultValue); }
Utils { public static void closeQuietly( InputStream in ) { if( in != null ) { try { in.close(); } catch( IOException e ) { } } } private  Utils(); static boolean isEmptyOrWhitespaces( String s ); static String capitalize( String s ); static String removeFileExtension( String filename ); static List<String> splitNicely( String toSplit, String separator ); static List<String> splitNicelyWithPattern( String toSplit, String patternSeparator ); static List<String> filterEmptyValues( List<String> values ); static String format( Collection<String> items, String separator ); static String expandTemplate(String s, Properties params); static void closeQuietly( InputStream in ); static void closeQuietly( OutputStream out ); static void closeQuietly( Reader reader ); static void closeQuietly( Writer writer ); static void copyStreamUnsafelyUseWithCaution( InputStream in, OutputStream os ); static void copyStreamSafely( InputStream in, ByteArrayOutputStream os ); static void copyStream( InputStream in, File outputFile ); static void copyStream( File inputFile, File outputFile ); static void copyStream( File inputFile, OutputStream os ); static void writeStringInto( String s, File outputFile ); static void appendStringInto( String s, File outputFile ); static String readFileContent( File file ); static String readFileContentQuietly( File file, Logger logger ); static String readUrlContent( String url ); static String readUrlContentQuietly( String url, Logger logger ); static Properties readPropertiesFile( File file ); static Properties readPropertiesFileQuietly( File file, Logger logger ); static Properties readPropertiesQuietly( String fileContent, Logger logger ); static void writePropertiesFile( Properties properties, File file ); static String cleanNameWithAccents( String name ); static void createDirectory( File directory ); static List<File> listAllFiles( File directory ); static String updateProperties( String propertiesContent, Map<String,String> keyToNewValue ); static List<File> listAllFiles( File directory, String fileExtension ); static List<File> listAllFiles( File directory, boolean includeDirectories ); static List<File> listDirectFiles( File directory, String fileExtension ); static List<File> listDirectories( File root ); static Map<String,byte[]> storeDirectoryResourcesAsBytes( File directory ); static Map<String,byte[]> storeDirectoryResourcesAsBytes( File directory, List<String> exclusionPatteners ); static Map<String,String> storeDirectoryResourcesAsString( File directory ); static String computeFileRelativeLocation( File rootDirectory, File subFile ); static void extractZipArchive( File zipFile, File targetDirectory ); static void extractZipArchive( File zipFile, File targetDirectory, String entryPattern, String removedEntryPrefix ); static boolean isAncestor( File ancestorCandidate, File file ); static void deleteFilesRecursively( File... files ); static void deleteFilesRecursivelyAndQuietly( File... files ); static String writeExceptionButDoNotUseItForLogging( Throwable t ); static void logException( Logger logger, Level logLevel, Throwable t, String message ); static void logException( Logger logger, Level logLevel, Throwable t ); static void logException( Logger logger, Throwable t ); static void closeStatement( PreparedStatement ps, Logger logger ); static void closeStatement( Statement st, Logger logger ); static void closeResultSet( ResultSet resultSet, Logger logger ); static void closeConnection( Connection conn, Logger logger ); static boolean isAncestorFile( File potentialAncestor, File file ); static void copyDirectory( File source, File target ); static Map.Entry<String,Integer> findUrlAndPort( String url ); static String getValue(Map<String,String> map, String key, String defaultValue);  }