Forums Register Login

java.io.FileNotFoundException:(The network path was not found) thrown after 4 minutes

+Pie Number of slices to send: Send
Hi,

I have a requirement to transfer the file to remote systems.

I wanted to do it with the FileChannel and don't want to use FTPClient.

FileChannel ic = new FileInputStream(sourcePath).getChannel();
FileChannel oc = new FileOutputStream("\\\\117.254.24.154\\Endhiran").getChannel());
ic.transferTo(0, ic.size(), oc);
ic.close();
oc.close();

Application throws an exception when it reach FileChannel oc = new FileOutputStream("\\\\117.254.24.154\\Endhiran").getChannel()); with unavailable destination path.

There is no issues when the destinationpath is reachable.

I wanted to know why does it takes 4 minutes to throw exception when the destination path is not available.

Can anyone advice on how to make it throw exception immediately when the dest is not reachable?

Thanks in advance.

Thanks
Vinoth
+Pie Number of slices to send: Send
Hi Vinoth,

to shorten the idle time you could throw your own TimeoutException.
See http://www.javacoffeebreak.com/articles/network_timeouts/

Cheers,
Ramon
Pay attention! Tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 3731 times.
Similar Threads
Java NIO error (anyone?)
copying file without messing up the content.
File Channel
Testing for exceptions
transfer files from one folder to another in java
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:23:39.