app/src/main/java/fi/finwe/orion360/sdk/pro/examples/MainMenu.java
private boolean zip(String zipFile, boolean compress, String... filenames) {
		Log.i(TAG, "Creating a zip file: " + zipFile);

		try {
			BufferedInputStream origin;
			FileOutputStream out = new FileOutputStream(zipFile);
			ZipOutputStream zip = new ZipOutputStream(new BufferedOutputStream(out));

			int bufferSize = 1024;
			byte [] buffer = new byte[bufferSize];
			for (String filename : filenames) {
				Log.i(TAG, " adding to zip: " + filename);

				FileInputStream in = new FileInputStream(filename);
				origin = new BufferedInputStream(in, bufferSize);
				ZipEntry entry = new ZipEntry(filename.substring(filename.lastIndexOf(
						File.separator) + 1));
				if (!compress) {
					long bytes = new File(filename).length();
					long crc = crc32(filename);
					Log.i(TAG, " size: " + bytes + " crc32: " + Long.toHexString(crc));

					entry.setMethod(ZipEntry.STORED);
					entry.setSize(bytes);
					entry.setCompressedSize(bytes);
					entry.setCrc(crc);
				}
				zip.putNextEntry(entry);
				int read;
				while (( read = origin.read(buffer, 0, bufferSize)) != -1) {
					zip.write(buffer, 0, read);
				}
				origin.close();
			}
			zip.close();

			return true;
		} catch(Exception e) {
			Log.e(TAG, "Failed to create a zip package: " + zipFile, e);
		}

		return false;
	}
/**
	 * Create a zip package from given file(s).
	 *
	 * @param zipFile The zip file to be created, with full path.
	 * @param compress Set to true to compress files, false to just wrap them into a zip container.
	 * @param filenames The full path to the file(s) to be included to the zip file.
	 * @return true if package was successfully created, else false.
	 */
Create a zip package from given file(s).
@param zipFile The zip file to be created, with full path.
@param compress Set to true to compress files, false to just wrap them into a zip container.
@param filenames The full path to the file(s) to be included to the zip file.
@return true if package was successfully created, else false.
Create a zip package from given file ( s ) . @param zipFile The zip file to be created with full path . @param compress Set to true to compress files false to just wrap them into a zip container . @param filenames The full path to the file ( s ) to be included to the zip file . @return true if package was successfully created else false .
private boolean zip(String zipFile, boolean compress, String... filenames) {
		Log.i(TAG, "Creating a zip file: " + zipFile);
		try {
			BufferedInputStream origin;
			FileOutputStream out = new FileOutputStream(zipFile);
			ZipOutputStream zip = new ZipOutputStream(new BufferedOutputStream(out));
			int bufferSize = 1024;
			byte [] buffer = new byte[bufferSize];
			for (String filename : filenames) {
				Log.i(TAG, " adding to zip: " + filename);
				FileInputStream in = new FileInputStream(filename);
				origin = new BufferedInputStream(in, bufferSize);
				ZipEntry entry = new ZipEntry(filename.substring(filename.lastIndexOf(
						File.separator) + 1));
				if (!compress) {
					long bytes = new File(filename).length();
					long crc = crc32(filename);
					Log.i(TAG, " size: " + bytes + " crc32: " + Long.toHexString(crc));
					entry.setMethod(ZipEntry.STORED);
					entry.setSize(bytes);
					entry.setCompressedSize(bytes);
					entry.setCrc(crc);
				}
				zip.putNextEntry(entry);
				int read;
				while (( read = origin.read(buffer, 0, bufferSize)) != -1) {
					zip.write(buffer, 0, read);
				}
				origin.close();
			}
			zip.close();
			return true;
		} catch(Exception e) {
			Log.e(TAG, "Failed to create a zip package: " + zipFile, e);
		}
		return false;
	}
private boolean zip ( String zipFile , boolean compress , String ... filenames ) { Log . i ( TAG , "Creating a zip file: " + zipFile ) ; try { BufferedInputStream origin ; FileOutputStream out = new FileOutputStream ( zipFile ) ; ZipOutputStream zip = new ZipOutputStream ( new BufferedOutputStream ( out ) ) ; int bufferSize = 1024 ; byte [ ] buffer = new byte [ bufferSize ] ; for ( String filename : filenames ) { Log . i ( TAG , " adding to zip: " + filename ) ; FileInputStream in = new FileInputStream ( filename ) ; origin = new BufferedInputStream ( in , bufferSize ) ; ZipEntry entry = new ZipEntry ( filename . substring ( filename . lastIndexOf ( File . separator ) + 1 ) ) ; if ( ! compress ) { long bytes = new File ( filename ) . length ( ) ; long crc = crc32 ( filename ) ; Log . i ( TAG , " size: " + bytes + " crc32: " + Long . toHexString ( crc ) ) ; entry . setMethod ( ZipEntry . STORED ) ; entry . setSize ( bytes ) ; entry . setCompressedSize ( bytes ) ; entry . setCrc ( crc ) ; } zip . putNextEntry ( entry ) ; int read ; while ( ( read = origin . read ( buffer , 0 , bufferSize ) ) != - 1 ) { zip . write ( buffer , 0 , read ) ; } origin . close ( ) ; } zip . close ( ) ; return true ; } catch ( Exception e ) { Log . e ( TAG , "Failed to create a zip package: " + zipFile , e ) ; } return false ; }
Create a zip package from given file(s).
Create a zip package from given file ( s ) .