import java.io.*; import java.util.StringTokenizer; public class Pakkija{ public static void main(String argumendid[]) throws IOException{ BufferedReader klaviatuur=new BufferedReader( new InputStreamReader(System.in) ); PrintWriter valja=new PrintWriter(new FileWriter("pakitud.txt")); System.out.println("Palun failinimi, mida soovid pakkida:"); String failinimi=klaviatuur.readLine(); BufferedReader sisse=new BufferedReader( new FileReader(failinimi) ); String lause=sisse.readLine(); while(lause!=null){ StringTokenizer st=new StringTokenizer(lause, " "); while(st.hasMoreTokens()){ String sona=st.nextToken(); valja.print(sona); // System.out.print(sona); } lause=sisse.readLine(); } valja.close(); System.out.println("Pakitud andmed asuvad failis pakitud.txt."); } }