-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpr3132File.java
38 lines (38 loc) · 1.28 KB
/
pr3132File.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.io.*;
import java.util.*;
class pr3132File
{
public static void main(String[] args) throws IOException
{
Scanner sc = new Scanner(System.in);
//write content in the file
FileWriter filein = new FileWriter ("C:\\Java\\Practical Exam\\Source.txt");
System.out.println("Enter the Content in File 1 :");
String input = sc.nextLine();
filein.write(input);
filein.close();
//read content in a file
FileReader fileout = new FileReader ("C:\\Java\\Practical Exam\\Source.txt");
int x;
System.out.println("Content Present in the file : ");
while((x=fileout.read())!= -1)
{
char y;
y = (char) x;
System.out.print(y);
}
fileout.close();
//Copy the content from file1 to file2
FileReader fin = new FileReader ("C:\\Java\\Practical Exam\\Source.txt");
FileWriter fout = new FileWriter ("C:\\Java\\Practical Exam\\Destination.txt");
while((x=fin.read())!= -1)
{
char y;
y = (char) x;
fout.write(y);
}
fin.close();
fout.close();
System.out.println(" \n SuccessFully Copy the content ");
}
}