Created
May 8, 2014 14:26
-
-
Save frankcash/48e33662bf16d777035c to your computer and use it in GitHub Desktop.
Zippy Zoop
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
public class ZippyZoop { | |
public static void zippyZoop(String fileName, String zipName){ | |
try{ | |
byte[] buffer = new byte[1024]; | |
FileOutputStream fos = new FileOutputStream(zipName); | |
ZipOutputStream zos = new ZipOutputStream(fos); | |
File srcFile = new File(fileName); | |
FileInputStream fis = new FileInputStream(srcFile); | |
//something | |
zos.putNextEntry(new ZipEntry(srcFile.getName())); | |
int length; | |
while((length = fis.read(buffer))>0){ | |
zos.write(buffer, 0, length); | |
} | |
zos.closeEntry(); | |
fis.close(); | |
zos.close(); | |
}catch(IOException ioe){ | |
//something something something | |
} | |
} | |
/** | |
* @param args the command line arguments | |
*/ | |
public static void main(String[] args) { | |
zippyZoop("C:\\Users\\fcash\\Documents\\test\\foo.txt", "C:\\Users\\fcash\\Documents\\test\\aphrodite.zip"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment