Code That Made Me Cry, #CTMMC™

95% of all code makes me cry. The other 5% are white space.

Copying Files (Java, #35 / 50)

private static void copyFile(File sourceFile, File destFile)
        throws IOException {
    if (!sourceFile.exists()) {
    if (!destFile.exists()) {
    FileChannel source = null;
    FileChannel destination = null;
    source = new FileInputStream(sourceFile).getChannel();
    destination = new FileOutputStream(destFile).getChannel();
    if (destination != null && source != null) {
        destination.transferFrom(source, 0, source.size());
    if (source != null) {
    if (destination != null) {

And this is how we Java folks copy files in 2013. And this doesn't even handle exceptions. Yeah, I know. Apache commons-io. Why can't there be a JDK method for this? Answer given by Janusz on Stack Overflow


comments powered by Disqus

Submit your own Code That Made You Cry

Send us your own example of code that made you cry! Please include:

Send the above to All accepted submissions will be licensed as CC BY-SA 3.0. Submit only code of a compatible license.

Note that we may choose not to publish some submissions if we feel they're not appropriate. We hope you understand.

Don't let your SQL code make you cry!

Use jOOQ, instead of JDBC.

jOOQ generates Java code from your database and lets you build typesafe SQL queries through its fluent API.

Don't let your SQL code make you cry! Get back in control of your SQL with jOOQ.