-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.java
More file actions
48 lines (37 loc) · 1.11 KB
/
file.java
File metadata and controls
48 lines (37 loc) · 1.11 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
package emailClient;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;
public class file {
private ArrayList<String> email_recipeints = new ArrayList<String>();
public void write(String str) throws IOException{
File f = new File("clientList.txt");
if(f.exists()) {
FileWriter fw = new FileWriter(f, true);
PrintWriter pw = new PrintWriter(fw);
pw.println(str);
pw.close();
fw.close();
}else {
FileWriter fw = new FileWriter(f, false);
PrintWriter pw = new PrintWriter(fw);
pw.print(str);
pw.close();
fw.close();
}
readAll();
}
public void readAll() throws IOException{
File f = new File("clientList.txt");
Scanner scanner = new Scanner(f);
while(scanner.hasNextLine()) {
//load all the recipients in to an array list
email_recipeints.add(scanner.nextLine());}
}
public ArrayList<String> getarray(){
return email_recipeints;
}
}