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);
如果我的項目已移動,則路徑必須更改。 我問我的項目目錄改變時目標路徑如何改變?複製在java項目的同一目錄中?
類似[this](http://stackoverflow.com/questions/778187/getting-directory-path-to-class-file-containing-main)? –