-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteFile.java
More file actions
37 lines (32 loc) · 1.03 KB
/
Copy pathWriteFile.java
File metadata and controls
37 lines (32 loc) · 1.03 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
import java.util.Scanner;
import java.io.File;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class WriteFile {
public static void main(String[] args)
{
try
{
File file1 = new File("input.txt");
Scanner scanner = new Scanner(file1);
File file = new File("HardWords.txt");
BufferedWriter writer = new BufferedWriter(new FileWriter(file, true));
while(scanner.hasNext())
{
String[] words = scanner.next().split("\\d+");
for(String s : words)
{
writer.write(s);
writer.write("\n");
}
}
System.out.println("bruh");
writer.close();
scanner.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
}