1
int reval = fcCari.showOpenDialog(this);
String sourcePath = fcCari.getSelectedFile().getAbsolutePath();
String targetPath = "C:\\Users\\nadzar\\Downloads\\Compressed\\JavaSQLite\\resource\\";
    targetPath += fcCari.getSelectedFile().getName();
    if ((reval == JFileChooser.APPROVE_OPTION)) {
            File source = new File(sourcePath);
            File target = new File(targetPath);
            copyFile(source, target);
            targetPathFoto=targetPath;
            tambahFoto(targetPathFoto);
    }
    else{
        JOptionPane.showMessageDialog(rootPane, "Batal Menambahkan Foto");
        tambahFoto(this.targetFoto);
    }
    System.out.println(targetPathFoto);

If my project has moved, the path must be changed. I ask how can the target path change while my project directory has changed?

Toon Krijthe
  • 52,876
  • 38
  • 145
  • 202

1 Answers1

0

Use properties file for this purpose, what you need to do is change the property value.

# app home, build absolute paths in code using this path
app.home=path_to_home_directory

Use java.util.Properties to read these properties.

See examples at mkyong.

Nandkumar Tekale
  • 16,024
  • 8
  • 58
  • 85