Class ConsecutivelyNumberedFilenames
- java.lang.Object
-
- net.coobird.thumbnailator.name.ConsecutivelyNumberedFilenames
-
- All Implemented Interfaces:
java.lang.Iterable<java.io.File>
public class ConsecutivelyNumberedFilenames extends java.lang.Object implements java.lang.Iterable<java.io.File>This class is used to produce file names based on a given format string and an internal counter which increments every time a new file name is produced.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classConsecutivelyNumberedFilenames.ConsecutivelyNumberedFilenamesIterator
-
Field Summary
Fields Modifier and Type Field Description private java.util.Iterator<java.io.File>iterThe iterator to return upon theiterator()method being called.
-
Constructor Summary
Constructors Constructor Description ConsecutivelyNumberedFilenames()Instantiates anConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are consecutively numbered beginning from0.ConsecutivelyNumberedFilenames(int start)Instantiates anConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are consecutively numbered beginning from the given value.ConsecutivelyNumberedFilenames(java.io.File dir)Instantiates anConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are consecutively numbered beginning from0, with the directory specified.ConsecutivelyNumberedFilenames(java.io.File dir, int start)Instantiates anConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are consecutively numbered beginning from from the given value, with the directory specified.ConsecutivelyNumberedFilenames(java.io.File dir, java.lang.String format)Instantiates anConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are based on a format string, located in the directory specified.ConsecutivelyNumberedFilenames(java.io.File dir, java.lang.String format, int start)Instantiates anConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are based on a format string, located in the directory specified.ConsecutivelyNumberedFilenames(java.lang.String format)Instantiates anConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are based on a format string.ConsecutivelyNumberedFilenames(java.lang.String format, int start)Instantiates anConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are based on a format string.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidcheckDirectory(java.io.File dir)java.util.Iterator<java.io.File>iterator()Returns an iterator which generates file names according to the rules specified by this object.
-
-
-
Field Detail
-
iter
private final java.util.Iterator<java.io.File> iter
The iterator to return upon theiterator()method being called.
-
-
Constructor Detail
-
ConsecutivelyNumberedFilenames
public ConsecutivelyNumberedFilenames()
Instantiates an
ConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are consecutively numbered beginning from0.File name sequence
0123
and so on.
-
ConsecutivelyNumberedFilenames
public ConsecutivelyNumberedFilenames(int start)
Instantiates an
ConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are consecutively numbered beginning from the given value.File name sequence
For a case where the given value is
5:5678
and so on.
- Parameters:
start- The value from which to start counting.
-
ConsecutivelyNumberedFilenames
public ConsecutivelyNumberedFilenames(java.io.File dir) throws java.io.IOExceptionInstantiates an
ConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are consecutively numbered beginning from0, with the directory specified.File name sequence
For a case where the parent directory is
/foo/bar/:/foo/bar/0/foo/bar/1/foo/bar/2/foo/bar/3
and so on.
- Parameters:
dir- The directory in which the files are to be located.- Throws:
java.io.IOException- If the specified directory path is not a directory, or if does not exist.
-
ConsecutivelyNumberedFilenames
public ConsecutivelyNumberedFilenames(java.lang.String format)
Instantiates an
ConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are based on a format string. The numbering will be consecutive from0.The format string should contain the string
%dwhich will be replaced with a consecutively counted number. Additional formatting can be applied. For more details, please refer to the section on Numeric formatting in the Java API specification for theFormatterclass.File name sequence
For a case where the format string is
image-%d:image-0image-1image-2image-3
and so on.
- Parameters:
format- The format string to use.
-
ConsecutivelyNumberedFilenames
public ConsecutivelyNumberedFilenames(java.io.File dir, int start) throws java.io.IOExceptionInstantiates an
ConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are consecutively numbered beginning from from the given value, with the directory specified.File name sequence
For a case where the parent directory is
/foo/bar/, and the specified value is5:/foo/bar/5/foo/bar/6/foo/bar/7/foo/bar/8
and so on.
- Parameters:
dir- The directory in which the files are to be located.start- The value from which to start counting.- Throws:
java.io.IOException- If the specified directory path is not a directory, or if does not exist.
-
ConsecutivelyNumberedFilenames
public ConsecutivelyNumberedFilenames(java.io.File dir, java.lang.String format) throws java.io.IOExceptionInstantiates an
ConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are based on a format string, located in the directory specified. The numbering will be consecutively counted from0.The format string should contain the string
%dwhich will be replaced with a consecutively counted number. Additional formatting can be applied. For more details, please refer to the section on Numeric formatting in the Java API specification for theFormatterclass.File name sequence
For a case where the parent directory is
/foo/bar/, with the format stringimage-%d:/foo/bar/image-0/foo/bar/image-1/foo/bar/image-2/foo/bar/image-3
and so on.
- Parameters:
dir- The directory in which the files are to be located.format- The format string to use.- Throws:
java.io.IOException- If the specified directory path is not a directory, or if does not exist.
-
ConsecutivelyNumberedFilenames
public ConsecutivelyNumberedFilenames(java.lang.String format, int start)Instantiates an
ConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are based on a format string. The numbering will be consecutive from the specified value.The format string should contain the string
%dwhich will be replaced with a consecutively counted number. Additional formatting can be applied. For more details, please refer to the section on Numeric formatting in the Java API specification for theFormatterclass.File name sequence
For a case where the parent directory is
/foo/bar/, and the specified value is5, with the format stringimage-%d:image-5image-6image-7image-8
and so on.
- Parameters:
format- The format string to use.start- The value from which to start counting.
-
ConsecutivelyNumberedFilenames
public ConsecutivelyNumberedFilenames(java.io.File dir, java.lang.String format, int start) throws java.io.IOExceptionInstantiates an
ConsecutivelyNumberedFilenamesobject which returnsFiles with file names which are based on a format string, located in the directory specified. The numbering will be consecutive from the specified value.The format string should contain the string
%dwhich will be replaced with a consecutively counted number. Additional formatting can be applied. For more details, please refer to the section on Numeric formatting in the Java API specification for theFormatterclass.File name sequence
For a case where the parent directory is
/foo/bar/, and the specified value is5, with format stringimage-%d:/foo/bar/image-5/foo/bar/image-6/foo/bar/image-7/foo/bar/image-8
and so on.
- Parameters:
dir- The directory in which the files are to be located.format- The format string to use.start- The value from which to start counting.- Throws:
java.io.IOException- If the specified directory path is not a directory, or if does not exist.
-
-
Method Detail
-
checkDirectory
private static void checkDirectory(java.io.File dir) throws java.io.IOException- Throws:
java.io.IOException
-
iterator
public java.util.Iterator<java.io.File> iterator()
Returns an iterator which generates file names according to the rules specified by this object.- Specified by:
iteratorin interfacejava.lang.Iterable<java.io.File>- Returns:
- An iterator which generates file names.
-
-