MCPcopy Create free account
hub / github.com/ReadyTalk/avian / getInputStream

Method getInputStream

classpath/java/util/zip/ZipFile.java:88–133  ·  view source on GitHub ↗
(ZipEntry entry)

Source from the content-addressed store, hash-verified

86 }
87
88 public InputStream getInputStream(ZipEntry entry) throws IOException {
89 final int pointer = ((MyEntry) entry).pointer();
90 int method = compressionMethod(window, pointer);
91 int size = compressedSize(window, pointer);
92 InputStream in = new MyInputStream(file, fileData(window, pointer), size);
93
94 final int Stored = 0;
95 final int Deflated = 8;
96
97 switch (method) {
98 case Stored:
99 return in;
100
101 case Deflated:
102 return new InflaterInputStream(in, new Inflater(true)) {
103 int remaining = uncompressedSize(window, pointer);
104
105 public int read() throws IOException {
106 byte[] buffer = new byte[1];
107 int c = read(buffer);
108 return (c < 0 ? c : (buffer[0] & 0xFF));
109 }
110
111 public int read(byte[] buffer) throws IOException {
112 return read(buffer, 0, buffer.length);
113 }
114
115 public int read(byte[] buffer, int offset, int length)
116 throws IOException
117 {
118 int c = super.read(buffer, offset, length);
119 if (c > 0) {
120 remaining -= c;
121 }
122 return c;
123 }
124
125 public int available() {
126 return remaining;
127 }
128 };
129
130 default:
131 throw new IOException();
132 }
133 }
134
135 private static boolean equal(byte[] a, int aOffset, byte[] b, int bOffset,
136 int size)

Callers 2

mainMethod · 0.95
verifyContentsMethod · 0.95

Calls 5

compressionMethodMethod · 0.95
compressedSizeMethod · 0.95
fileDataMethod · 0.95
uncompressedSizeMethod · 0.95
pointerMethod · 0.65

Tested by 2

mainMethod · 0.76
verifyContentsMethod · 0.76