I have the code for how to delete a line in a file but after the delete operation is performed there is a new blank line in the file which is separating the content above the deleted line and the content below it.
try {
List<String> line = Files.readAllLines(path,StandardCharsets.ISO_8859_1);
for (int i = 0; i < line.size(); i++) {
if (dataStoreLines.get(i).contains(key)) {
dataStoreLines.set(i, "");
break;
}
}
Suppose the file contains
Line 1
Line 2
Line 3
if I want to delete Line 2
The modified file with my code is like
Line 1
Line 3
The empty line in between is not getting deleted
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…