Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- import java.io.*;
- public class Esercizio2
- {
- public static int riduciFile (String nomeFile, int max) throws IOException
- {
- int cont=0;
- FileReader f_in= new FileReader(nomeFile);
- BufferedReader in= new BufferedReader(f_in);
- String nuovo=nomeFile+"_ridotto.txt";
- FileWriter f_out=new FileWriter(nuovo);
- PrintWriter out=new PrintWriter(f_out);
- String s="";
- while(in.readLine()!=null)
- {
- s=in.readLine();
- if(s.length()<=max)
- {
- out.println(s);
- cont++;
- }
- }
- f_in.close();
- in.close();
- f_out.close();
- out.close();
- return cont;
- }
- }
Add Comment
Please, Sign In to add comment