Guest User

Untitled

a guest
Oct 17th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3.  
  4. public class FileEcho {
  5.  
  6. File file;
  7. Scanner scanner;
  8. String filename = "words.txt";
  9. File file1 ;
  10. PrintWriter pw ;
  11. void echo() {
  12. try {
  13. String line;
  14.  
  15. file = new File( filename);
  16. scanner = new Scanner( file );
  17. file1 = new File("brabuhr.txt");
  18. pw = new PrintWriter(file1);
  19.  
  20.  
  21. while (scanner.hasNextLine()) {
  22. line = scanner.nextLine();
  23. String s = new StringBuilder(line).reverse().toString();
  24.  
  25. pw.println(s);
  26. }
  27. scanner.close();
  28. } catch(FileNotFoundException e) {
  29. System.out.println( "Could not find or open file <"+filename+">n"+e
  30. );
  31. }
  32. }
  33.  
  34. public static void main(String[] args) {
  35. new FileEcho().echo();
  36. }
  37. }
Add Comment
Please, Sign In to add comment