Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileNotFoundException;
  3. import java.io.IOException;
  4. import java.io.PrintWriter;
  5. import java.util.Scanner;
  6.  
  7.  
  8. public class input {
  9.    
  10.  
  11.     public static void main(String[]args) throws FileNotFoundException,IOException{
  12.        
  13.         //prompt for input
  14.        
  15.         String inputFileName = args[0];
  16.         String outputFileName = args[1];
  17.        
  18.        
  19.         // construct scanner and printwriter for reading and writing
  20.        
  21.         File inputFile = new File(inputFileName);
  22.         Scanner filescn = new Scanner(inputFile);
  23.         PrintWriter out = new PrintWriter(outputFileName);
  24.         int lineNumber = 1;
  25.        
  26.         while (filescn.hasNextLine())
  27.         {
  28.             String line = filescn.nextLine();
  29.             StringBuffer revLine = new StringBuffer(line).reverse();
  30.             out.println(revLine);
  31.             lineNumber++;
  32.         }
  33.    
  34.         filescn.close();
  35.         out.close();
  36.         }
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement