Answer the question
In order to leave comments, you need to log in
Why can't copy the file?
There is the following piece of code.
final File myself = new File(new File(getClass().getProtectionDomain().getCodeSource().getLocation().getFile()).getParentFile(), "Consultant.jar");
final File tmp = File.createTempFile("Chat", ".tmp");
try(
final ReadableByteChannel rbc = Channels.newChannel(new URL(url).openStream())
)
{
try (final FileOutputStream fos = new FileOutputStream(tmp)) {
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.flush();
}
}
if(!tmp.renameTo(myself))
{
try {
Files.move(tmp.toPath(), myself.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
e.printStackTrace();
throw new Exception("Cant rename tmp-download version '" + tmp.getAbsolutePath() + "' to exec-binary '" + myself.getAbsolutePath() + "'\r\n" + e.getMessage());
}
}
Answer the question
In order to leave comments, you need to log in
Copy, not move gives?
If it does, then most likely some process is holding the file.
If it does not, then something with the rights.
And what is the original exception on stdout?
Offhand - %20 instead of a space is not pleasant.
Yes, the fact of the matter is that apart from this, nothing else is written to the log
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question