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