Use factory method for creating FileInputStream
This commit is contained in:
@@ -9,6 +9,7 @@ import java.io.File;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import static com.threerings.getdown.Log.log;
|
import static com.threerings.getdown.Log.log;
|
||||||
@@ -52,7 +53,7 @@ public final class LaunchUtil
|
|||||||
{
|
{
|
||||||
// create the file that instructs Getdown to upgrade
|
// create the file that instructs Getdown to upgrade
|
||||||
File vfile = new File(appdir, "version.txt");
|
File vfile = new File(appdir, "version.txt");
|
||||||
try (PrintStream ps = new PrintStream(new FileOutputStream(vfile))) {
|
try (PrintStream ps = new PrintStream(Files.newOutputStream(vfile.toPath()))) {
|
||||||
ps.println(newVersion);
|
ps.println(newVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public final class VersionUtil
|
|||||||
{
|
{
|
||||||
long fileVersion = -1;
|
long fileVersion = -1;
|
||||||
try (BufferedReader bin =
|
try (BufferedReader bin =
|
||||||
new BufferedReader(new InputStreamReader(new FileInputStream(vfile), UTF_8))) {
|
new BufferedReader(new InputStreamReader(Files.newInputStream(vfile.toPath()), UTF_8))) {
|
||||||
String vstr = bin.readLine();
|
String vstr = bin.readLine();
|
||||||
if (!StringUtil.isBlank(vstr)) {
|
if (!StringUtil.isBlank(vstr)) {
|
||||||
fileVersion = Long.parseLong(vstr);
|
fileVersion = Long.parseLong(vstr);
|
||||||
@@ -81,7 +81,7 @@ public final class VersionUtil
|
|||||||
public static long readReleaseVersion (File relfile, String versRegex)
|
public static long readReleaseVersion (File relfile, String versRegex)
|
||||||
{
|
{
|
||||||
try (BufferedReader in =
|
try (BufferedReader in =
|
||||||
new BufferedReader(new InputStreamReader(new FileInputStream(relfile), UTF_8))) {
|
new BufferedReader(new InputStreamReader(Files.newInputStream(relfile.toPath()), UTF_8))) {
|
||||||
String line = null, relvers = null;
|
String line = null, relvers = null;
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
if (line.startsWith("JAVA_VERSION=")) {
|
if (line.startsWith("JAVA_VERSION=")) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.net.Proxy;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
@@ -188,7 +189,7 @@ public final class ProxyUtil {
|
|||||||
|
|
||||||
public static void saveProxy (Application app, String host, String port) {
|
public static void saveProxy (Application app, String host, String port) {
|
||||||
File pfile = app.getLocalPath("proxy.txt");
|
File pfile = app.getLocalPath("proxy.txt");
|
||||||
try (PrintStream pout = new PrintStream(new FileOutputStream(pfile))) {
|
try (PrintStream pout = new PrintStream(Files.newOutputStream(pfile.toPath()))) {
|
||||||
if (!StringUtil.isBlank(host)) {
|
if (!StringUtil.isBlank(host)) {
|
||||||
pout.println("host = " + host);
|
pout.println("host = " + host);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user