1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| public class SuppLignVide {
public static void deleteLine(String f1, String f2) throws IOException {
BufferedReader input = new BufferedReader(new FileReader(f1));
BufferedWriter output = new BufferedWriter(new FileWriter(f2));
String line = "";
while ((line = input.readLine()) != null) {
if (line.compareTo("#")<0) {
output.write(line);
output.newLine();
output.close();
}
}
}
public static void main(String[] args) throws IOException {
String f1 = "mon_chemin1.txt";
String f2 = "mon_chemin2.txt";
deleteLine(f1, f2);
}
} |
Partager