-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest1.java
38 lines (27 loc) · 908 Bytes
/
test1.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
//Ranye Mclendon
//EEGR 409
//Lecture 4 Lab 3
//02/24/2022
//This is a program reads and copy a text file
import java.io.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Q3 {
public static void main (String[] args) throws IOException{
//open and reads file
File myfile = new File("lab4_3.txt");
Scanner in = new Scanner(myfile);
//open output file
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("copy_of_lab4_3.txt")));
//read line by line
System.out.print("Copying the file...");
while(in.hasNextLine());{
String buffer = in.nextLine();
out.println(buffer);
}
System.out.print("File Copied.");
in.close();
out.close();
}
}