import java.io.*; class demo { public static void main(String args[])throws IOException { String inputFile = "C:\\Users\\USER\\Desktop\\java code\\helo.txt"; String outputFile = "C:\\Users\\USER\\Desktop\\java code\\he.txt"; FileInputStream f = new FileInputStream("C:\\Users\\USER\\Desktop\\java code\\helo.txt"); DataOutputStream bao = new DataOutputStream(new FileOutputStream(outputFile)); DataInputStream bai = new DataInputStream(new FileInputStream(inputFile)); int size = bai.available(); int i; while((i=bai.read())!=-1) { bao.write(i); } bai.close(); bai = new DataInputStream(new FileInputStream(inputFile)); // Reopen for resetting while (bai.available() > 0) { int data = bai.readInt(); if (data % 2 == 0) { bao.writeInt(data); } } bai.close(); bao.close(); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter