forked from I2P_Developers/i2p.i2p
* findbugs: mostly stream closure fixes in router, apps, core
This commit is contained in:
@ -39,11 +39,12 @@ public class CertUtil {
|
||||
*/
|
||||
public static boolean saveCert(Certificate cert, File file) {
|
||||
OutputStream os = null;
|
||||
PrintWriter wr = null;
|
||||
try {
|
||||
// Get the encoded form which is suitable for exporting
|
||||
byte[] buf = cert.getEncoded();
|
||||
os = new SecureFileOutputStream(file);
|
||||
PrintWriter wr = new PrintWriter(os);
|
||||
wr = new PrintWriter(os);
|
||||
wr.println("-----BEGIN CERTIFICATE-----");
|
||||
String b64 = Base64.encode(buf, true); // true = use standard alphabet
|
||||
for (int i = 0; i < b64.length(); i += LINE_LENGTH) {
|
||||
|
@ -355,9 +355,10 @@ public class FileUtil {
|
||||
File f = new File(filename);
|
||||
if (!f.exists()) return null;
|
||||
FileInputStream fis = null;
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
fis = new FileInputStream(f);
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
|
||||
in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
|
||||
List<String> lines = new ArrayList<String>(maxNumLines > 0 ? maxNumLines : 64);
|
||||
String line = null;
|
||||
while ( (line = in.readLine()) != null) {
|
||||
@ -377,7 +378,7 @@ public class FileUtil {
|
||||
} catch (IOException ioe) {
|
||||
return null;
|
||||
} finally {
|
||||
if (fis != null) try { fis.close(); } catch (IOException ioe) {}
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -391,14 +391,16 @@ public class TranslateReader extends FilterReader {
|
||||
}
|
||||
|
||||
private static void test(String file) throws IOException {
|
||||
FileInputStream fio = new FileInputStream(file);
|
||||
TranslateReader r = new TranslateReader(I2PAppContext.getGlobalContext(),
|
||||
"net.i2p.router.web.messages",
|
||||
new FileInputStream(file));
|
||||
fio);
|
||||
int c;
|
||||
while ((c = r.read()) >= 0) {
|
||||
System.out.print((char)c);
|
||||
}
|
||||
System.out.flush();
|
||||
r.close();
|
||||
}
|
||||
|
||||
/** @param files ignore 0 */
|
||||
|
Reference in New Issue
Block a user