Class DeleteLinesByIndexInFile

java.lang.Object
io.github.astrapi69.file.modify.DeleteLinesByIndexInFile
All Implemented Interfaces:
FileChangeable, BiFunction<Integer,String,String>

public class DeleteLinesByIndexInFile extends Object implements FileChangeable
The class DeleteLinesByIndexInFile implements the FileChangeable interface to delete specific lines in a file based on a list of line indexes.
  • Constructor Details

    • DeleteLinesByIndexInFile

      public DeleteLinesByIndexInFile(List<Integer> lineIndexesToDelete)
      Instantiates a new DeleteLinesByIndexInFile with the given list of line indexes to delete
      Parameters:
      lineIndexesToDelete - the line indexes to delete
  • Method Details

    • apply

      public String apply(Integer lineIndex, String line)
      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 interface BiFunction<Integer,String,String>
      Parameters:
      lineIndex - the index of the current line
      line - the content of the current line
      Returns:
      the modified line, or null if the line should be deleted