Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Ue3;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.PrintStream;
- import java.util.Scanner;
- public class DoubleSpace_Execptions {
- public static void doubleSpace(String x, String y){
- File r = new File("C:\\Users\\Nico\\Desktop\\Uni\\Programmieren\\"+x);
- File w = new File("C:\\Users\\Nico\\Desktop\\Uni\\Programmieren\\"+y);
- Scanner read = null;
- try {
- read = new Scanner(r);
- } catch (FileNotFoundException e) {
- System.out.println(e.getMessage());
- }
- PrintStream write = null;
- try {
- write = new PrintStream(new FileOutputStream(w, true));
- } catch (FileNotFoundException e) {
- System.out.println(e.getMessage());
- }
- while (read.hasNextLine()){
- String line = read.nextLine();
- write.println(line);
- if(read.hasNextLine()){
- write.println("");
- }
- }
- write.close();
- }
- public static void main(String[] args){
- doubleSpace("vonhier.txt", "nachhier.txt");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement