/** * Checks the contents of the specified zip entry. * * @param file file to be checked * @param data expected file contents * @throws IOException I/O exception */ private static void checkEntry(final String file, final byte[] data) throws IOException { ZipFile zf = null; try { zf = new ZipFile(TMPZIP); final ZipEntry ze = zf.getEntry(file); assertNotNull("File not found: " + file, ze); final DataInputStream is = new DataInputStream(zf.getInputStream(ze)); final byte[] dt = new byte[(int) ze.getSize()]; is.readFully(dt); assertTrue( "Wrong contents in file \"" + file + "\":" + Prop.NL + "Expected: " + string(data) + Prop.NL + "Found: " + string(dt), eq(data, dt)); } finally { if (zf != null) zf.close(); } }
public static void loadAnimations() { System.out.println("Testing"); int i = 0; try { GZIPInputStream gzipDataFile = new GZIPInputStream(new FileInputStream(getDir() + "frames.dat")); DataInputStream dataFile = new DataInputStream(gzipDataFile); GZIPInputStream gzipIndexFile = new GZIPInputStream(new FileInputStream(getDir() + "frames.idx")); DataInputStream indexFile = new DataInputStream(gzipIndexFile); int length = indexFile.readInt(); for (i = 0; i < length; i++) { int id = indexFile.readInt(); int invlength = indexFile.readInt(); byte[] data = new byte[invlength]; dataFile.readFully(data); allFrames[id] = data; } indexFile.close(); dataFile.close(); } catch (Exception e) { System.out.println("Error: " + i); e.printStackTrace(); } try { GZIPInputStream gzipDataFile = new GZIPInputStream(new FileInputStream(getDir() + "skinlist.dat")); DataInputStream dataFile = new DataInputStream(gzipDataFile); GZIPInputStream gzipIndexFile = new GZIPInputStream(new FileInputStream(getDir() + "skinlist.idx")); DataInputStream indexFile = new DataInputStream(gzipIndexFile); int length = indexFile.readInt(); for (i = 0; i < length; i++) { int id = indexFile.readInt(); int invlength = indexFile.readInt(); byte[] data = new byte[invlength]; dataFile.readFully(data); allSkinlist[id] = data; } indexFile.close(); dataFile.close(); } catch (Exception e) { System.out.println("Error: " + i); e.printStackTrace(); } }
@Override public void readData(DataInputStream in) throws IOException { x = in.readInt(); z = in.readInt(); biomes = in.readBoolean(); bitmask = in.readShort(); additionalBitmask = in.readShort(); int tempLength = in.readInt(); byte[] compressedChunkData = new byte[tempLength]; in.readFully(compressedChunkData, 0, tempLength); int i = 0; for (int j = 0; j < 16; j++) i += bitmask >> j & 1; int k = 12288 * i; if (biomes) k += 256; chunkData = new byte[k]; Inflater inflater = new Inflater(); inflater.setInput(compressedChunkData, 0, tempLength); try { inflater.inflate(chunkData); } catch (DataFormatException dataformatexception) { chunkData = null; } catch (OutOfMemoryError error) { System.gc(); try { inflater.end(); inflater = new Inflater(); inflater.setInput(compressedChunkData, 0, tempLength); inflater.inflate(chunkData); } catch (DataFormatException dataformatexception) { chunkData = null; } catch (OutOfMemoryError error2) { chunkData = null; } } finally { inflater.end(); } }
public void func_73267_a(DataInputStream p_73267_1_) throws IOException { short word0 = p_73267_1_.readShort(); field_73585_g = p_73267_1_.readInt(); field_73589_c = new int[word0]; field_73586_d = new int[word0]; field_73590_a = new int[word0]; field_73588_b = new int[word0]; field_73584_f = new byte[word0][]; if (field_73591_h.length < field_73585_g) { field_73591_h = new byte[field_73585_g]; } p_73267_1_.readFully(field_73591_h, 0, field_73585_g); byte abyte0[] = new byte[0x30100 * word0]; Inflater inflater = new Inflater(); inflater.setInput(field_73591_h, 0, field_73585_g); try { inflater.inflate(abyte0); } catch (DataFormatException dataformatexception) { throw new IOException("Bad compressed data format"); } finally { inflater.end(); } int i = 0; for (int j = 0; j < word0; j++) { field_73589_c[j] = p_73267_1_.readInt(); field_73586_d[j] = p_73267_1_.readInt(); field_73590_a[j] = p_73267_1_.readShort(); field_73588_b[j] = p_73267_1_.readShort(); int k = 0; for (int l = 0; l < 16; l++) { k += field_73590_a[j] >> l & 1; } int i1 = 2048 * (5 * k) + 256; field_73584_f[j] = new byte[i1]; System.arraycopy(abyte0, i, field_73584_f[j], 0, i1); i += i1; } }