Ex1: ... File f1 = new File("Ex1Swap1.txt"); File f2 = new File("Ex1Swap2.txt"); File holder = new File("Ex1Swap1.txt"); f1.renameTo(f2); f2.renameTo(f1); ... Ex3 Write a programm which read a given .txt file line by line and creates a new b.txt file containing only the lines in even position import java.io.*; class CopyEvenLines{ public static void main(String args[]) { String s; int i = 1; try { FileReader fr = new FileReader("a.txt"); BufferedReader br = new BufferedReader(fr); FileOutputStream f = new FileOutputStream("b.txt"); PrintStream os = new PrintStream(f); while ((s = br.readLine()) != null) { if (i % 2 == 0) os.println(s); i++; } fr.close(); os.close(); } catch (IOException e) { System.out.println("Errore di input/output: " + e); } } } Ex4: Write a program which read line by line a .txt file with a given name .txt and it writes in a new .txt file with name .txt the following lines Number of lines: xx Number of characters: yy where xx and yy are respectively the number of lines and characters contained in the input file. import java.io.*; class LinesAndCharacterCounter{ public static void main(String args[]) { String s; int i = 0; int c = 0; try { FileReader fr = new FileReader(".txt"); BufferedReader br = new BufferedReader(fr); FileOutputStream f = new FileOutputStream("fileCountingStuffs.txt"); PrintStream os = new PrintStream(f); while ((s = br.readLine()) != null) { c = c + s.length(); i++; } os.println("Number of lines:" + i); os.println("Number of characters:" + c); fr.close(); os.close(); } catch (IOException e) { System.out.println("No file to read: " + e); } } } Ex3 write a programm which generate a .txt file by shuffeling two txt file. That is: if the generated file is named A.txt and the two files are B.txt and C.txt, then the first line of A.txt is the first line of B.txt, the second line of A.txt is the first line of B.txt, the third line of A.txt is the second line of B.txt, the fourth line of A.txt is the second line of B.txt, and so on import java.io.*; class UnisciFile{ public static void main(String args[]) { String s; try { FileReader fr1 = new FileReader("f1.txt"); BufferedReader br1 = new BufferedReader(fr1); FileReader fr2 = new FileReader("f2.txt"); BufferedReader br2 = new BufferedReader(fr2); FileOutputStream f = new FileOutputStream("unione.txt"); PrintStream os = new PrintStream(f); while ((s = br1.readLine()) != null) { os.println(s); } while ((s = br2.readLine()) != null) { os.println(s); } fr1.close(); fr2.close(); os.close(); } catch (IOException e) { System.out.println("Errore di input/output: " + e); } } } Ex4: Write a programm which swap the name of two files.