-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCredential.java
More file actions
38 lines (35 loc) · 1.3 KB
/
Credential.java
File metadata and controls
38 lines (35 loc) · 1.3 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
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Credential {
public static String readApiKey() {
String apiKey = null;
try (BufferedReader reader = new BufferedReader(new FileReader("api_key.txt"))) {
String line;
while ((line = reader.readLine()) != null) {
if (line.startsWith("api_key")) {
apiKey = line.split("=")[1].trim().replace("\"", ""); // Remove quotation marks
break;
}
}
} catch (IOException e) {
System.err.println("Error reading API key: " + e.getMessage());
}
return apiKey;
}
public static String readUsername() {
String username = null;
try (BufferedReader reader = new BufferedReader(new FileReader("api_key.txt"))) {
String line;
while ((line = reader.readLine()) != null) {
if (line.startsWith("USERNAME")) {
username = line.split("=")[1].trim().replace("\"", ""); // Remove quotation marks
break;
}
}
} catch (IOException e) {
System.err.println("Error reading username: " + e.getMessage());
}
return username;
}
}