Grant Callant Development Blog

Fall Development

After a hiatus from Winter Quarter, comprised of Spring and Summer Quarter (a full class schedule over Summer no less)- I am FINALLY back to developing! This return will be short-lived of course, as Fall Quarter starts in less than two weeks. I am going to make use of the time that I have to finally master GUI programming and hopefully learn some UX design (just learning from my textbook Intro to Java Programming, Comprehensive Version (10th Edition)). So far I’ve learned some Java-FX basics and I’ve FINALLY learned what Lambda Expressions are! Event Handlers in GUI programming seem like a great place to use them- although I’m sure they have some great uses in other places as well.

I’m really hoping to tackle a GUI for my Batch Zip Extract program. I know it’s simple and maybe not the most useful program but I just want to finish what I’ve started and it seems like a great place to utilize a simple GUI system. So stay tuned to hopefully see a revamped program replete with a GUI.

I really wanted to also finish (or at least get some work in) on an iOS app that I started programming during Winter break. I even had some design ideas and storyboarding done by a talented young woman whom I met while working on a project with JAC Systems. She goes by the design handle VoSkorbia and I wanted to give her a shout-out for the great ideas that she has contributed to the app. I’m not sure if I will have enough time to complete that app before Fall Quarter starts but it is on my list! Stay tuned for hopefully more updates on that app soon.

In other news, I have received notification that I have officially been accepted into Eastern Washington University’s Master of Science in Computer Science program! I was also offered a Graduate Assistant position. I have not officially been told what my primary assignment will be yet- but I’ve been told unofficially that I might be teaching a Computer Literacy class. I’m actually really excited. While some might dread teaching such a class- I love teaching about computers and hopefully I can pass along some of the passion that I have for computers to others.

Thanks for reading and subscribe or check back later for more updates on my app and schooling development!

Grant

Batch Extract Zip Files Using Java & Zip4j

Introduction to the problem


I am an avid gamer, and I enjoy collecting games; however, I am also currently a “poor college student”, and “triple A” titles usually don’t fit in my budget. This is where indie games come in. Indie games, as the name suggests, are developed independently of any large development corporation, usually by a individual person or a small team. These games are typically priced much lower than your average AAA title (less developers, and no publisher to take a large cut)(Brown, Peter 2014), and are therefore more affordable for me. I find that I like to try different things a lot, and games are no exception. This leads me to Humble Bundle.


Humble Bundle Example

I love Humble Bundle because it combines a package of great games, at a great price that I choose. Also, I find that indie games tend to be a “labor of love” by their developers. As far as Humble Bundle is concerned, that usually means that the soundtracks are included with the copies of the games. Have you ever had a game that stuck with you because of the haunting or beautiful music? I am also an avid music collector, so getting these awesome soundtracks with the games is a dream-come-true.


Getting the games is usually easy enough from Humble Bundle. They offer drm-free copies that you can download, but the majority of the times I was after the steam key to add it to my steam library. The soundtracks for the games were available in mp3 format, or even flac for the audiophile. I usually quickly redeem the steam key, but I had let the soundtracks stack up in my Humble Bundle download queue, telling myself that I would download them some other time. I finally had the audacity to download all 212 of them at once and stored them in a directory on my hard drive. Okay, but now what? I had a serious problem. I was not going to manually go through unzipping and waiting on 200+ zip files that were 100+ MegaBytes (there were also a few audio books that were over 2 GigaBytes). I needed some way to extract each of these zip files and have them copy to my iTunes library. (Now the fun part).


Writing the Java batch zip extract


I figured there might be some utility already built that would allow you to easily batch extract zips to a directory, but where is the fun in that? I decided to write a program in Java over Christmas Break that would allow me to batch extract zips to any directory I specified. The Java Util has a built in library for handling zip files, but it requires a lot of boilerplate code (mostly from byte array buffers, to output to a zip output stream) and I realized that getting this to work with 100MB files, (let alone 2 GB files) was going to be very difficult. This is when I found Zip4j, an open-source library that can handle any size zip file.



Zip4j Java unzipEngine Method

What I love about Zip4j, is that it had an understandable API, and allowed for password-protected zip files. I downloaded the source library for Zip4j, and happily hummed along making methods that I was easily able to pass to Zip4j. At last, I was finally complete, and the time came to test out my code on a few “innocuous” zip files before hurdling my massive 212 zip file soundtrack library. It didn’t work▬That always leaves you scratching your head for a second. I mean, as a programmer, you don’t usually expect your code to work the first time you give it “real data”, but you hope it does. I checked over my code, walked through debug, there it was- Zip4j had thrown an exception I hadn’t caught- NonZipFileException. I looked back at the “zip file” I had specified. It was a rar file. I slapped my forehead and added in some handling lines for this exception and changed to an actual zip file. This time it worked.


Of course the next question was, would it work on such a large directory of files? Would it corrupt all the zip files that had taken hours to download? I decided to “bite the bullet” and find out. I watched in the command output as the utility quickly moved through all the files and cleanly deposited a separate folder for each album into my iTunes library. This made me smile. As a programmer, the best part of programming for me is in solving the puzzle and finally seeing the expected outcome. Don’t get me wrong, I love the journey, but being able to finally look out over the “Everest” summit when the program runs is breathtaking.


Conclusion


This was a fun little project. It is really simple code, but it does what it needs to in my opinion. I have included links to the source in my GitHub, as well as I have provided the executable jar file in the hopes that someone else might find it useful if they have a large amount of zip files which need to be extracted (with or without passwords). It is a simple little utility, (command line only at this point) you provide the source and destination locations, as well as the password(s), or location to a text file with a list of passwords (they must be in order of file appearance). I have also provided links to the Zip4j library. Zip4j does most of the heavy lifting, I have to give it most of the credit here.

Thanks for reading,

Grant


References

Brown, Peter 2014. Gamespot.com. Access April 9, 2015.