3
24/10/2024 7:00 μμ
Εκκινητής θέματος
1 Απάντηση
2
24/10/2024 7:57 μμ
Here is the solution:
import java.io.*;
public class Pr_01_OddLines {
public static void main(String[] args) throws IOException {
File fileIn1 = new File("resources\\01_OddLinesIn.txt");
try (BufferedReader bf = new BufferedReader(new FileReader(fileIn1))) {//SURROUND WITH try with resources FOR THE EXCEPTIONS
String readLine;
int line = 0;
while ((readLine = bf.readLine()) != null) {
if (line % 2 != 0) {//CHECKING WHETHER THE ROW IS ODD
System.out.println(readLine);
}
line++;
}
}
}
}

