-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewProfileWindow.java
More file actions
42 lines (33 loc) · 901 Bytes
/
ViewProfileWindow.java
File metadata and controls
42 lines (33 loc) · 901 Bytes
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
import java.util.Scanner;
import javax.swing.JOptionPane;
import java.io.*;
/**
* This program reads from the Profile text file and
* displays its information for the user.
* @author Julian Velez
*/
public class ViewProfileWindow {
/**
* constructor
*/
public ViewProfileWindow() {
try {
// Open the file
File file = new File("Profile");
Scanner inputFile = new Scanner(file);
// create a StringBuilder object to hold the file's contents
StringBuilder output = new StringBuilder();
// read lines from the file until we reach the end
while (inputFile.hasNext()) {
String line = inputFile.nextLine();
output.append(line + "\n");
}
inputFile.close();
// display the output
JOptionPane.showMessageDialog(null, output.toString());
}
catch (IOException ie) {
JOptionPane.showMessageDialog(null, "File not found");
}
}
}