com.softwaresandbox.pubgclient.PubgApiKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pubg-api-client Show documentation
Show all versions of pubg-api-client Show documentation
Java library to interface with the PUBG developer API.
The newest version!
package com.softwaresandbox.pubgclient;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Paths;
import java.util.Properties;
public class PubgApiKey {
private static String pubgApiKey;
public static String getPubgApiKey() {
if (pubgApiKey == null) {
pubgApiKey = readPubgApiKeyFromKeyFile();
}
return pubgApiKey;
}
public static void setPubgApiKey(String pubgApiKey) {
PubgApiKey.pubgApiKey = pubgApiKey;
}
@SuppressWarnings("ThrowFromFinallyBlock")
private static String readPubgApiKeyFromKeyFile() {
Properties prop = new Properties();
InputStream input = null;
String result = "";
try {
input = new FileInputStream(Paths.get(System.getProperty("user.home"), ".key", "pubgapi.key").toString());
prop.load(input);
result = prop.getProperty("development");
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy