This commit is contained in:
Luca Conte 2022-12-01 16:02:52 +01:00
parent 6c6523afd2
commit 7b547be58e
4 changed files with 58 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,32 @@
import java.io.*;
import java.util.*;
/**
* Klasse zum duplizieren von Leerzeilen in Textdateien
*/
public class DoubleSpace {
public static void main(String[] args) throws FileNotFoundException {
doubleSpace("test.txt","out.txt");
}
/**
* Duplizierzt Leerzeilen bzw Zeilenumbrueche der
* Datei inputFileName und speichert das Ergebnis in
* outputFileName ab
*/
public static void doubleSpace(String inputFileName, String outputFileName) throws FileNotFoundException {
Scanner input = new Scanner(new File(inputFileName));
PrintStream output = new PrintStream(new File(outputFileName));
if (input.hasNextLine()) {
output.println(input.nextLine());
}
while (input.hasNextLine()) {
output.println();
output.println(input.nextLine());
}
output.close();
input.close();
}
}

17
uebungen/u24/out.txt Normal file
View File

@ -0,0 +1,17 @@
hallo
hier
sind
leerzeichen
yes

9
uebungen/u24/test.txt Normal file
View File

@ -0,0 +1,9 @@
hallo
hier
sind
leerzeichen
yes