copy 1 to 100 numbeer from file one and paste to others has some error
Thu Oct 03 2024 16:30:01 GMT+0000 (Coordinated Universal Time)
Saved by
@dark
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();
}
}
content_copyCOPY
Comments