Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. package Ue3;
  2.  
  3. import java.io.File;
  4. import java.io.FileNotFoundException;
  5. import java.io.FileOutputStream;
  6. import java.io.PrintStream;
  7. import java.util.Scanner;
  8.  
  9. public class DoubleSpace_Execptions {
  10.  
  11. public static void doubleSpace(String x, String y){
  12. File r = new File("C:\\Users\\Nico\\Desktop\\Uni\\Programmieren\\"+x);
  13. File w = new File("C:\\Users\\Nico\\Desktop\\Uni\\Programmieren\\"+y);
  14. Scanner read = null;
  15. try {
  16. read = new Scanner(r);
  17. } catch (FileNotFoundException e) {
  18. System.out.println(e.getMessage());
  19. }
  20. PrintStream write = null;
  21. try {
  22. write = new PrintStream(new FileOutputStream(w, true));
  23. } catch (FileNotFoundException e) {
  24. System.out.println(e.getMessage());
  25. }
  26.  
  27. while (read.hasNextLine()){
  28. String line = read.nextLine();
  29. write.println(line);
  30. if(read.hasNextLine()){
  31. write.println("");
  32. }
  33. }
  34. write.close();
  35. }
  36.  
  37. public static void main(String[] args){
  38.  
  39. doubleSpace("vonhier.txt", "nachhier.txt");
  40.  
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement