Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package javaapplication1;
  7. import java.io.File;
  8. import java.io.FileNotFoundException;
  9. import java.io.FileWriter;
  10. import java.io.PrintWriter;
  11. import java.util.Scanner;
  12. import java.util.Random;
  13. /**
  14. *
  15. * @author 01603679
  16. */
  17. public class JavaApplication1 {
  18.  
  19. /**
  20. * @param args the command line arguments
  21. */
  22. public static void main(String[] args) throws IOExeption {
  23.  
  24. Scanner k = new Scanner(System.in);
  25. System.out.println("Enter input file name");
  26. String inputFile = k.nextLine();
  27.  
  28. System.out.println("Enter output file name");
  29. String outputFile = k.nextLine();
  30.  
  31. File input = new File(inputFile);
  32. Scanner s = new Scanner(input);
  33.  
  34. FileWriter output = new FileWriter(outputFile, true);
  35. PrintWriter outputFile = new PrintWriter(output);
  36.  
  37. while(s.hasNext())
  38. {
  39. String line = s.nextLine();
  40. outputFile.println(line);
  41. outputFile.println(rand.nextFloat());
  42. outputFile.println(rand.nextDouble());
  43. outputFile.println(rand.nextInt());
  44. outputFile.println(rand.nextInt(6)+1);
  45. }
  46. outputFile.close();
  47. s.close();
  48.  
  49. // TODO code application logic here
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement