public MyFile downloadFileFromFileID(int fileID) throws IOException, SQLException {

        Connection conn = (Connection) initiateFileDBConn()[0];
        CallableStatement cs = null;
        cs = conn.prepareCall("{CALL SP_GetFileUsingFileID(?)}");
        cs.setInt(1, fileID);

        ResultSet rs = cs.executeQuery();

        rs.next();

        MyFile mf = null;

        int id = rs.getInt(1);
        String filename = rs.getString(2);
        Date creationDate = rs.getDate(3);
        Blob blob = rs.getBlob(4);
        int taskID = rs.getInt(5);
        InputStream is = blob.getBinaryStream();

        // Creates a new file in the temp folder
        String suffix = "";
        String prefix = "";

        String[] tokens = filename.split("\\.(?=[^\\.]+$)");
        // SOURCE:  http://stackoverflow.com/questions/4545937/java-splitting-the-filename-into-a-base-and-extension
        // SOURCE: http://stackoverflow.com/questions/4416425/how-to-split-string-with-some-seperator-but-without-removing-that-seperator-in-j/4416576#4416576

        prefix = tokens[0];
        suffix = tokens[1];

//        System.out.println(prefix);
//        System.out.println(suffix);
//        System.out.println(tmpfolder);
        
        String tmpfolder = System.getProperty("java.io.tmpdir");
        File f = new File(tmpfolder+prefix+"."+suffix);

       // Write file to the temp folder
        FileOutputStream fos = new FileOutputStream(f);
        int b = 0;
        while ((b = is.read()) != -1) {
            fos.write(b);
        }
        fos.close();

        mf = new MyFile(id, filename, creationDate, f, taskID);

        return mf;
    }