Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- public class FileEcho {
- File file;
- Scanner scanner;
- String filename = "words.txt";
- File file1 ;
- PrintWriter pw ;
- void echo() {
- try {
- String line;
- file = new File( filename);
- scanner = new Scanner( file );
- file1 = new File("brabuhr.txt");
- pw = new PrintWriter(file1);
- while (scanner.hasNextLine()) {
- line = scanner.nextLine();
- String s = new StringBuilder(line).reverse().toString();
- pw.println(s);
- }
- scanner.close();
- } catch(FileNotFoundException e) {
- System.out.println( "Could not find or open file <"+filename+">n"+e
- );
- }
- }
- public static void main(String[] args) {
- new FileEcho().echo();
- }
- }
Add Comment
Please, Sign In to add comment