4242 * Most methods on this class are designed to work the same on both Unix and Windows.
4343 * Those that don't include 'System', 'Unix' or 'Windows' in their name.
4444 * <p>
45- * Most methods recognise both separators (forward and back), and both
46- * sets of prefixes. See the javadoc of each method for details.
45+ * Most methods recognize both separators (forward and back), and both
46+ * sets of prefixes. See the Javadoc of each method for details.
4747 * <p>
4848 * This class defines six components within a file name
4949 * (example C:\dev\project\file.txt):
@@ -359,7 +359,7 @@ private static String doNormalize(final String fileName, final char separator, f
359359 return null ;
360360 }
361361
362- failIfNullBytePresent (fileName );
362+ requireNonNullChars (fileName );
363363
364364 int size = fileName .length ();
365365 if (size == 0 ) {
@@ -551,7 +551,6 @@ public static boolean directoryContains(final String canonicalParent, final Stri
551551 return IOCase .SYSTEM .checkStartsWith (canonicalChild , canonicalParent );
552552 }
553553
554- //-----------------------------------------------------------------------
555554 /**
556555 * Converts all separators to the Unix separator of forward slash.
557556 *
@@ -591,7 +590,6 @@ public static String separatorsToSystem(final String path) {
591590 return isSystemWindows () ? separatorsToWindows (path ) : separatorsToUnix (path );
592591 }
593592
594- //-----------------------------------------------------------------------
595593 /**
596594 * Returns the length of the fileName prefix, such as <code>C:/</code> or <code>~/</code>.
597595 * <p>
@@ -789,11 +787,11 @@ public static String getPrefix(final String fileName) {
789787 return null ;
790788 }
791789 if (len > fileName .length ()) {
792- failIfNullBytePresent (fileName + UNIX_SEPARATOR );
790+ requireNonNullChars (fileName + UNIX_SEPARATOR );
793791 return fileName + UNIX_SEPARATOR ;
794792 }
795793 final String path = fileName .substring (0 , len );
796- failIfNullBytePresent (path );
794+ requireNonNullChars (path );
797795 return path ;
798796 }
799797
@@ -873,7 +871,7 @@ private static String doGetPath(final String fileName, final int separatorAdd) {
873871 return EMPTY_STRING ;
874872 }
875873 final String path = fileName .substring (prefix , endIndex );
876- failIfNullBytePresent (path );
874+ requireNonNullChars (path );
877875 return path ;
878876 }
879877
@@ -990,7 +988,7 @@ public static String getName(final String fileName) {
990988 if (fileName == null ) {
991989 return null ;
992990 }
993- failIfNullBytePresent (fileName );
991+ requireNonNullChars (fileName );
994992 final int index = indexOfLastSeparator (fileName );
995993 return fileName .substring (index + 1 );
996994 }
@@ -1001,7 +999,7 @@ public static String getName(final String fileName) {
1001999 * This may be used for poison byte attacks.
10021000 * @param path the path to check
10031001 */
1004- private static void failIfNullBytePresent (final String path ) {
1002+ private static void requireNonNullChars (final String path ) {
10051003 final int len = path .length ();
10061004 for (int i = 0 ; i < len ; i ++) {
10071005 if (path .charAt (i ) == 0 ) {
@@ -1116,7 +1114,7 @@ public static String removeExtension(final String fileName) {
11161114 if (fileName == null ) {
11171115 return null ;
11181116 }
1119- failIfNullBytePresent (fileName );
1117+ requireNonNullChars (fileName );
11201118
11211119 final int index = indexOfExtension (fileName );
11221120 if (index == NOT_FOUND ) {
@@ -1240,7 +1238,7 @@ public static boolean isExtension(final String fileName, final String extension)
12401238 if (fileName == null ) {
12411239 return false ;
12421240 }
1243- failIfNullBytePresent (fileName );
1241+ requireNonNullChars (fileName );
12441242
12451243 if (extension == null || extension .isEmpty ()) {
12461244 return indexOfExtension (fileName ) == NOT_FOUND ;
@@ -1265,7 +1263,7 @@ public static boolean isExtension(final String fileName, final String... extensi
12651263 if (fileName == null ) {
12661264 return false ;
12671265 }
1268- failIfNullBytePresent (fileName );
1266+ requireNonNullChars (fileName );
12691267
12701268 if (extensions == null || extensions .length == 0 ) {
12711269 return indexOfExtension (fileName ) == NOT_FOUND ;
@@ -1295,7 +1293,7 @@ public static boolean isExtension(final String fileName, final Collection<String
12951293 if (fileName == null ) {
12961294 return false ;
12971295 }
1298- failIfNullBytePresent (fileName );
1296+ requireNonNullChars (fileName );
12991297
13001298 if (extensions == null || extensions .isEmpty ()) {
13011299 return indexOfExtension (fileName ) == NOT_FOUND ;
0 commit comments