-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStoredPasswords.java
More file actions
41 lines (37 loc) · 1.68 KB
/
StoredPasswords.java
File metadata and controls
41 lines (37 loc) · 1.68 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
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class StoredPasswords {
String appData = System.getenv("LOCALAPPDATA");
String passPath = appData+"\\savedpass.txt";
public void showSavedPasswords(){
try(BufferedReader reader = new BufferedReader(new FileReader(passPath))){
System.out.println("\n===Your Saved Passwords===");
// Peek the first line
if (!reader.ready()) {
System.out.println("No Saved Passwords! ");
return;
}
System.out.println("-----------------------------------------------------------------------");
System.out.printf("| %-3s | %-15s | %-20s | %-20s |\n", "No", "Website", "Email", "Password");
System.out.println("-----------------------------------------------------------------------");
int i = 1;
String line;
while ((line = reader.readLine()) != null) {
String[] myArray = line.split(",");
if (myArray.length == 3) {
System.out.printf("| %-3d | %-15s | %-20s | %-20s |\n", i, myArray[0], myArray[1], myArray[2]);
i++;
}
}
System.out.println("-----------------------------------------------------------------------");
}
catch (FileNotFoundException e){
System.out.println("Could Not Locate Saved Passwords File");
}
catch(IOException e){
System.out.println("Something went wrong while reading saved file");
}
}
}