It looks like you're calling theoutput.getClass() before you've defined theoutput, so that's never going to work. Marcin's suggestion should fix that - you might as well use a class literal if you can.
One further point - casting the return value to File is unnecessary - the return type is T, so it will already be File in that call.
That's because getClass() returns a Class<?>, without any generic information. The main way to get a Class object with generic information is to use a class literal. Class.getSuperclass and Class.asSubclass return a Class object with some generic information but it still has a wildcard type.