Package io.github.astrapi69.file.modify
Class DeleteLinesByIndexInFile
java.lang.Object
io.github.astrapi69.file.modify.DeleteLinesByIndexInFile
- All Implemented Interfaces:
FileChangeable
,BiFunction<Integer,
String, String>
The class
DeleteLinesByIndexInFile
implements the FileChangeable
interface to
delete specific lines in a file based on a list of line indexes.-
Constructor Summary
ConstructorsConstructorDescriptionDeleteLinesByIndexInFile
(List<Integer> lineIndexesToDelete) Instantiates a newDeleteLinesByIndexInFile
with the given list of line indexes to delete -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.function.BiFunction
andThen
-
Constructor Details
-
DeleteLinesByIndexInFile
Instantiates a newDeleteLinesByIndexInFile
with the given list of line indexes to delete- Parameters:
lineIndexesToDelete
- the line indexes to delete
-
-
Method Details
-
apply
Applies the deletion logic to the specified line. If the current line index is in the list of indexes to delete, the method returns null, indicating that this line should be skipped. Otherwise, it returns the line with a newline character.- Specified by:
apply
in interfaceBiFunction<Integer,
String, String> - Parameters:
lineIndex
- the index of the current lineline
- the content of the current line- Returns:
- the modified line, or null if the line should be deleted
-