forked from Konloch/bytecode-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJarLoader.java
More file actions
59 lines (48 loc) · 1.16 KB
/
JarLoader.java
File metadata and controls
59 lines (48 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package jd.cli.loader;
import jd.core.loader.LoaderException;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class JarLoader extends BaseLoader
{
private ZipFile zipFile;
public JarLoader(File file) throws LoaderException
{
super(file);
if (! (file.exists() && file.isFile()))
{
throw new LoaderException("'" + codebase + "' is not a directory");
}
try
{
this.zipFile = new ZipFile(codebase);
}
catch (IOException e)
{
throw new LoaderException("Error reading from '" + codebase + "'");
}
}
public DataInputStream load(String internalPath)
throws LoaderException
{
ZipEntry zipEntry = this.zipFile.getEntry(internalPath);
if (zipEntry == null)
{
throw new LoaderException("Can not read '" + internalPath + "'");
}
try
{
return new DataInputStream(this.zipFile.getInputStream(zipEntry));
}
catch (IOException e)
{
throw new LoaderException("Error reading '" + internalPath + "'");
}
}
public boolean canLoad(String internalPath)
{
return this.zipFile.getEntry(internalPath) != null;
}
}