Commit 778b9bb8 authored by Skylot's avatar Skylot

fix: resolve lint errors in resource save methods

parent 57dd9e61
......@@ -5,7 +5,6 @@ import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
......@@ -70,10 +69,10 @@ public class ResContainer implements Comparable<ResContainer> {
public static ResContainer singleBinaryFile(String name, InputStream content) {
ResContainer resContainer = new ResContainer(name, Collections.emptyList());
try {
// TODO: don't store binary files in memory
resContainer.binary = new ByteArrayInputStream(IOUtils.toByteArray(content));
}
catch(IOException e) {
LOG.warn("Contents of the binary resource '{}' not saved, got exception {}", name, e);
} catch (Exception e) {
LOG.warn("Contents of the binary resource '{}' not saved, got exception", name, e);
}
return resContainer;
}
......
......@@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory;
import jadx.api.ResourceFile;
import jadx.core.codegen.CodeWriter;
import jadx.core.utils.files.FileUtils;
import jadx.core.utils.files.ZipSecurity;
import static jadx.core.utils.files.FileUtils.prepareFile;
......@@ -89,16 +90,16 @@ public class ResourcesSaver implements Runnable {
return;
}
InputStream binary = rc.getBinary();
if(binary != null) {
if (binary != null) {
try {
outFile.getParentFile().mkdirs();
FileOutputStream binaryFileStream = new FileOutputStream(outFile);
FileUtils.makeDirsForFile(outFile);
try (FileOutputStream binaryFileStream = new FileOutputStream(outFile)) {
IOUtils.copy(binary, binaryFileStream);
binaryFileStream.close();
} finally {
binary.close();
}
catch(IOException e) {
LOG.warn("Resource '{}' not saved, got exception {}", rc.getName(), e);
} catch (Exception e) {
LOG.warn("Resource '{}' not saved, got exception", rc.getName(), e);
}
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment