Skip to content

Commit cff6eb3

Browse files
committed
fixed NoSuchFileException
1 parent f0394a9 commit cff6eb3

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/main/java/me/katze225/Obfuscator.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
import java.io.FileOutputStream;
1515
import java.io.IOException;
16+
import java.nio.file.Files;
17+
import java.nio.file.Path;
18+
import java.nio.file.Paths;
1619
import java.util.ArrayList;
1720
import java.util.HashMap;
1821
import java.util.List;
@@ -47,6 +50,10 @@ public void run() {
4750

4851
private void loadClasses() throws IOException {
4952
System.out.println("Reading JAR file: " + settings.getInputPath());
53+
Path inputPath = Paths.get(settings.getInputPath());
54+
if (!Files.exists(inputPath)) {
55+
throw new IOException("Input JAR file not found: " + settings.getInputPath());
56+
}
5057
JarFile jarFile = new JarFile(settings.getInputPath());
5158
jarFile.stream().forEach(entry -> {
5259
try {
@@ -108,6 +115,10 @@ private List<ITransformer> buildTransformers() {
108115
private void writeOutput() throws IOException {
109116
System.out.println("Writing JAR file: " + settings.getOutputPath());
110117
try (JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(settings.getOutputPath()))) {
118+
Path inputPath = Paths.get(settings.getInputPath());
119+
if (!Files.exists(inputPath)) {
120+
throw new IOException("Input JAR file not found: " + settings.getInputPath());
121+
}
111122
JarFile inputJar = new JarFile(settings.getInputPath());
112123

113124
inputJar.stream().forEach(entry -> {

0 commit comments

Comments
 (0)