Add a few more try-with-resources
This commit is contained in:
@@ -1241,8 +1241,9 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_latest != null) {
|
if (_latest != null) {
|
||||||
try (InputStream in = ConnectionUtil.open(_latest, 0, 0).getInputStream()) {
|
try (InputStream in = ConnectionUtil.open(_latest, 0, 0).getInputStream();
|
||||||
BufferedReader bin = new BufferedReader(new InputStreamReader(in));
|
InputStreamReader reader = new InputStreamReader(in);
|
||||||
|
BufferedReader bin = new BufferedReader(reader)) {
|
||||||
for (String[] pair : Config.parsePairs(bin, Config.createOpts(false))) {
|
for (String[] pair : Config.parsePairs(bin, Config.createOpts(false))) {
|
||||||
if (pair[0].equals("version")) {
|
if (pair[0].equals("version")) {
|
||||||
_targetVersion = Math.max(Long.parseLong(pair[1]), _targetVersion);
|
_targetVersion = Math.max(Long.parseLong(pair[1]), _targetVersion);
|
||||||
|
|||||||
@@ -22,25 +22,26 @@ public class AppletParamSigner
|
|||||||
{
|
{
|
||||||
public static void main (String[] args)
|
public static void main (String[] args)
|
||||||
{
|
{
|
||||||
try {
|
if (args.length != 7) {
|
||||||
if (args.length != 7) {
|
System.err.println("AppletParamSigner keystore storepass alias keypass " +
|
||||||
System.err.println("AppletParamSigner keystore storepass alias keypass " +
|
"appbase appname imgpath");
|
||||||
"appbase appname imgpath");
|
System.exit(255);
|
||||||
System.exit(255);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
String keystore = args[0];
|
String keystore = args[0];
|
||||||
String storepass = args[1];
|
String storepass = args[1];
|
||||||
String alias = args[2];
|
String alias = args[2];
|
||||||
String keypass = args[3];
|
String keypass = args[3];
|
||||||
String appbase = args[4];
|
String appbase = args[4];
|
||||||
String appname = args[5];
|
String appname = args[5];
|
||||||
String imgpath = args[6];
|
String imgpath = args[6];
|
||||||
String params = appbase + appname + imgpath;
|
String params = appbase + appname + imgpath;
|
||||||
|
|
||||||
|
try (FileInputStream fis = new FileInputStream(keystore);
|
||||||
|
BufferedInputStream bis = new BufferedInputStream(fis)) {
|
||||||
|
|
||||||
KeyStore store = KeyStore.getInstance("JKS");
|
KeyStore store = KeyStore.getInstance("JKS");
|
||||||
store.load(new BufferedInputStream(new FileInputStream(keystore)),
|
store.load(bis, storepass.toCharArray());
|
||||||
storepass.toCharArray());
|
|
||||||
PrivateKey key = (PrivateKey)store.getKey(alias, keypass.toCharArray());
|
PrivateKey key = (PrivateKey)store.getKey(alias, keypass.toCharArray());
|
||||||
Signature sig = Signature.getInstance(Digest.sigAlgorithm(Digest.VERSION));
|
Signature sig = Signature.getInstance(Digest.sigAlgorithm(Digest.VERSION));
|
||||||
sig.initSign(key);
|
sig.initSign(key);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.io.FileInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -70,8 +70,10 @@ public class Config
|
|||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
// annoyingly FileReader does not allow encoding to be specified (uses platform default)
|
// annoyingly FileReader does not allow encoding to be specified (uses platform default)
|
||||||
InputStreamReader input = new InputStreamReader(new FileInputStream(source), "UTF-8");
|
try (FileInputStream fis = new FileInputStream(source);
|
||||||
return parsePairs(input, opts);
|
InputStreamReader input = new InputStreamReader(fis, StandardCharsets.UTF_8)) {
|
||||||
|
return parsePairs(input, opts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user