-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfileStorage.java
More file actions
executable file
·46 lines (37 loc) · 1.19 KB
/
fileStorage.java
File metadata and controls
executable file
·46 lines (37 loc) · 1.19 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
import java.io.*;
import java.util.*;
class fileStorage
{
/* Using a resizable array to store files inserted into PMS */
private ArrayList<String> insertFile(File file) throws FileNotFoundException{
/* Scanner will parse strings using regular expressions */
Scanner scan;
ArrayList <String> list = new ArrayList<String>();
scan = new Scanner(file);
/* Read in all lines within text file */
while(scan.hasNext())
list.add(scan.next());
/* Close scanner */
scan.close();
return list;
}
public void retrieveFile(){
/* File in which previously entered details where written to */
File file = new File("C:/Users/Sean/Documents/OO/Code/Patient_Bio_File.txt");
try{
ArrayList <String> lines = insertFile(file);
for(int index = 0; index < lines.size(); index++){
/* If a full stop occurs, print a new line */
if(lines.get(index).contains("."))
System.out.println();
/* Print word in text file */
else
System.out.print(lines.get(index) + " ");
}
System.out.println("Patient file is logged...access file is 'Patient_Bio_File'.");
}
catch(IOException e){
e.printStackTrace();
}
}
}