/** * reads the content of an existing file in zipped blocks using the current domain * * @param path The path relative to the domain for the file * @param offset The offset in the file to start reading from * @param len The length of the block in bytes in zipped form * @return The contents of the file in zipped form */ public byte[] readFromFileZipped(String path, long offset, int len) { // int result=-1; byte[] buffer = null; try { if (_isLocal) { File tmpFile = new File(_rootFile.getCanonicalPath() + File.separatorChar + path); if (tmpFile.isFile()) { RandomAccessFile in = new RandomAccessFile(tmpFile, "r"); in.seek(offset); int totalBufSize = 0; int readResult = 0; buffer = new byte[len]; ByteArrayOutputStream bOut = new ByteArrayOutputStream(len); GZIPOutputStream zOut = new GZIPOutputStream(bOut, len); while (totalBufSize < len && in.getFilePointer() < in.length()) { readResult = in.read(buffer); if (readResult != -1) { zOut.write(buffer); // bufSize = bOut.size(); totalBufSize += readResult; } else { break; } } zOut.close(); in.close(); return bOut.toByteArray(); } } else { buffer = _remote.readFromFileZipped(_domain, path, offset, len); } } catch (Exception ex) { ex.printStackTrace(); } return buffer; }