33 lines
923 B
Java
33 lines
923 B
Java
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();
|
|
}
|
|
}
|