java.io.file renameTo return false

Had a issue today where a java function which moves files stopped working. I realised that Java`s io.file.renameTo only throws Exceptions for some scenarios. For some errors, it will only return false when something goes wrong.

Only getting true/false on a rather vital operation is rather silly, so my “fix” was to move over to a library from Apache, aka FileUtils.

So now i simply do this: FileUtils.moveFile(oldFile, newFile);

That function actually throws exceptions when something fails 🙂

class Foo is public, should be declared in a file named Foo.java

When working with Java you might encounter this error. The reason for this is that you have tried to declare a public class in a file with a different name. Each java file can only contain one public java class, which is named the same as the java file itself. If you need another class inside your other class you should looking into private inner classes.