Created
September 4, 2011 05:17
-
-
Save IndianGuru/1192307 to your computer and use it in GitHub Desktop.
File compression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "bundler/setup" | |
require 'zip/zip' | |
# Hard-coding the file names | |
file = "jruby-complete.jar" | |
zip = "zip.zip" | |
if File.exists?(file) | |
#Create a Zip object to put compressed data in | |
Zip::ZipFile.open(zip, true) do |zipfile| | |
begin | |
puts "#{file} is being added to the archive." | |
#add a file to the zip object | |
zipfile.add(file,file) | |
rescue Exception => e | |
puts "Error adding to zipfile: \n #{e}." | |
end | |
end | |
else | |
puts "\nFile could not be found." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment