Utils { public static String capitalize( String s ) { String result = s; if( ! Utils.isEmptyOrWhitespaces( s )) result = Character.toUpperCase( s.charAt( 0 )) + s.substring( 1 ).toLowerCase(); return result; } 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);  }
@Test public void testCapitalize() { Assert.assertEquals( "", Utils.capitalize( "" )); Assert.assertNull( Utils.capitalize( null )); Assert.assertEquals( "Toto", Utils.capitalize( "Toto" )); Assert.assertEquals( "Toto", Utils.capitalize( "tOTo" )); Assert.assertEquals( "Toto oops", Utils.capitalize( "tOTo oops" )); }