import java.io.*;

public class Filtro1 { 

public static void main(String[] args) { 

int totale=0; FileWriter file = null; 

if (args.length != 2) { 
System.out.println("Problemi di argomenti\n sono" + args.length); 
System.exit(1); } 

try { file = new FileWriter (args[0]); } 
catch (IOException e) 
{System.out.println("Errore. Problema nella apertura file."); 
System.exit(2); } 


filtra (file, args[1]); 
System.exit(0);

}


public static boolean isIn (String s, char a) {

for (int i=0; i < s.length(); i++) 
if (s.charAt(i) == a) return true; 
return false; 

} 

public static void filtra(FileWriter file, String s) { 

InputStreamReader in = new InputStreamReader(System.in);
OutputStreamWriter out = new OutputStreamWriter (System .out); 
int x; 

try { 

while ((x = in.read()) >= 0) { 

char ch = (char) x; 


// if (s. indexOf(ch) >= 0) continue;
/* il metodo indexOf trova la prima occorrenza del carattere nella stringa se non è presente, si restituisce un valore negativo */ 

if (!isIn (s,ch)) {out.write(ch); file.write(ch); }

// if (ch == '\n') out.flush();
/* al fine linea portiamo il buffer sull'uscita */ 

} 

} 
catch (IOException e){ 
System.out.println("Errore. Problema di I/O"); 
System.exit(3); } 

try { out.close(); file.close(); } 
catch (IOException e){
System.out.println("Errore. Problema di chiusura "); 
System.exit(4); } 

} 

} 
