Guest User

Untitled

a guest
Apr 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2. import java.io.*;
  3. public class Esercizio2
  4. {
  5.  
  6. public static int riduciFile (String nomeFile, int max) throws IOException
  7. {
  8. int cont=0;
  9. FileReader f_in= new FileReader(nomeFile);
  10. BufferedReader in= new BufferedReader(f_in);
  11. String nuovo=nomeFile+"_ridotto.txt";
  12. FileWriter f_out=new FileWriter(nuovo);
  13. PrintWriter out=new PrintWriter(f_out);
  14. String s="";
  15. while(in.readLine()!=null)
  16. {
  17. s=in.readLine();
  18. if(s.length()<=max)
  19. {
  20. out.println(s);
  21. cont++;
  22. }
  23. }
  24. f_in.close();
  25. in.close();
  26. f_out.close();
  27. out.close();
  28. return cont;
  29.  
  30. }
  31.  
  32. }
Add Comment
Please, Sign In to add comment