3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-14 19:25:51 +00:00

Utils: Remove closeUnchecked() helpers, use Guava instead.

This commit is contained in:
Andreas Schildbach 2018-02-22 10:09:30 +01:00
parent 2b765d8aa8
commit b6ecc380b8
2 changed files with 2 additions and 21 deletions

View File

@ -29,7 +29,6 @@ import org.spongycastle.crypto.digests.RIPEMD160Digest;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
@ -625,23 +624,4 @@ public class Utils {
List<String> lines = Resources.readLines(url, Charsets.UTF_8);
return Joiner.on('\n').join(lines);
}
// Can't use Closeable here because it's Java 7 only and Android devices only got that with KitKat.
public static InputStream closeUnchecked(InputStream stream) {
try {
stream.close();
return stream;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static OutputStream closeUnchecked(OutputStream stream) {
try {
stream.close();
return stream;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -18,6 +18,7 @@
package org.bitcoinj.kits;
import com.google.common.collect.*;
import com.google.common.io.Closeables;
import com.google.common.util.concurrent.*;
import org.bitcoinj.core.listeners.*;
import org.bitcoinj.core.*;
@ -149,7 +150,7 @@ public class WalletAppKit extends AbstractIdleService {
*/
public WalletAppKit setCheckpoints(InputStream checkpoints) {
if (this.checkpoints != null)
Utils.closeUnchecked(this.checkpoints);
Closeables.closeQuietly(checkpoints);
this.checkpoints = checkNotNull(checkpoints);
return this;
}