Guest User

Untitled

a guest
Jan 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. JFileChooser fc = new JFileChooser();
  2. int returnCode = fc.showSaveDialog(null);
  3. if (returnCode != JFileChooser.APPROVE_OPTION){
  4. System.exit(1);
  5. }
  6. FileReader fr= new FileReader(fc.getSelectedFile());
  7. BufferedReader br = new BufferedReader(fr);
  8. while (true) { //while true loop with a break
  9. int x;
  10. for(x=1;;x++){
  11. String aLine= br.readLine();
  12.  
  13. if (aLine==null) break;
  14. System.out.println(x+":"+aLine);
  15. }
  16. }
  17.  
  18. int saveCode = fc.showSaveDialog(null);
  19. if(saveCode == JFileChooser.APPROVE_OPTION);
  20. //System.exit(1);
  21.  
  22.  
  23. FileWriter fw = new FileWriter(fc.getSelectedFile());
  24. PrintWriter outputln = new PrintWriter(fw);
  25. BufferedReader br1 = new BufferedReader(fr);
  26. while (true) { // while true loop with a break
  27.  
  28. //for(x=1;;x++){
  29. String aLine = br1.readLine();
  30. if (aLine == null)
  31. break;
  32. outputln.println(":"+aLine);
  33.  
  34.  
  35. }
  36. Random randomGenerator = new Random();
  37. for (int idx = 1; idx <= 1; ++idx){
  38. int randomInt = randomGenerator.nextInt(500);
  39. System.out.println("all done, copied: "+ fc.getDescription(null) );
  40. System.out.println("There are " + " lines and "+ " characters.");
  41. System.out.println("Here is a random number between 1 and 500: "+ randomInt);
  42. System.exit(0);
  43. }
  44.  
  45.  
  46. System.exit(1);
  47. }
  48. }
Add Comment
Please, Sign In to add comment