0

I have the following code for check if a file exists on some path, if not, that file is copy from the project, and it works.

public static void verificarDB() throws IOException {
    File cygnus_db = new File(System.getProperty("user.home")+File.separator+".local"+File.separator+"cygnus"+File.separator+"cygnus_db_local.db");

    if(!cygnus_db.exists()) {

    File source = new File("src/assets/bd/cygnus_db_local.db");
    File target = new File(System.getProperty("user.home")+File.separator+".local"+File.separator+"cygnus"+File.separator+"cygnus_db_local.db");
    FileUtils.copyFile(source, target);
    }
}

But when i export my project to a runnable jar i get this exception:

java.io.FileNotFoundException: Source 'src/assets/bd/cygnus_db_local.db' does not exist at org.apache.commons.io.FileUtils.checkFileRequirements(FileUtils.java:1383) at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1060) at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1028) at pruebas.Main.verificarDB(Main.java:123) at pruebas.Main.main(Main.java:30)

What im doing wrong?

Victor Ortiz
  • 791
  • 1
  • 12
  • 23

0 Answers0