-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathq2ayushChauhan1922016.java
More file actions
70 lines (56 loc) · 1.94 KB
/
q2ayushChauhan1922016.java
File metadata and controls
70 lines (56 loc) · 1.94 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import java.util.*;
import java.lang.*;
import java.io.*;
import java.io.File;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
File myObj = new File("one.txt");
myObj.createNewFile();
File myObj2 = new File("two.txt");
myObj2.createNewFile();
File myObj3 = new File("three.txt");
myObj3.createNewFile();
Scanner sc = new Scanner(System.in);
String line1[] = new String[5];
String line2[] = new String[5];
System.out.println("enter lines for file 1");
for(int i=0;i<5;i++){
line1[i] = sc.nextLine();
}
System.out.println("enter lines for file 2");
for(int i=0;i<5;i++){
line2[i] = sc.nextLine();
}
for(int i=0;i<5;i++){
BufferedWriter out = new BufferedWriter(new FileWriter("one.txt"));
out.write(line1[i]);
out.newLine();
}
for(int i=0;i<5;i++){
BufferedWriter out = new BufferedWriter(new FileWriter("two.txt"));
out.write(line2[i]);
out.newLine();
}
for(int i=0;i<5;i++){
BufferedWriter out = new BufferedWriter(new FileWriter("three.txt"));
out.write(line1[i]);
out.newLine();
}
for(int i=0;i<5;i++){
BufferedWriter out = new BufferedWriter(new FileWriter("three.txt"));
out.write(line2[i]);
out.newLine();
}
System.out.println("content of three.txt");
for(int i=0;i<5;i++){
System.out.println(line2[i]);
}
for(int i=0;i<5;i++){
System.out.println(line1[1]);
}
}
}