Due to company policies, I cannot share the complete code here, but here is where the code fails:
try(InputStream in = new URL("URL with image file").openStream()){
Files.copy(in, Paths.get("file://newfile.png"));
} catch (Exception e) {
}
The Exception is:
java.net.ConnectException: Connection timed out: connect
The things I have tried:
Note: I'm trying to save an image from the URL. I have tried accessing the URL with my personal system and it's working. With my company system, it's not, even after adding the proxy.
Could someone please tell me why this is happening?
Sorry, it was my mistake. If anyone is seeing this:
The problem came from how I used proxy. If you are NOT able to connect to a website which is otherwise accessible via browser in same system, then you need a proxy in your java code.
For example:
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("google.com", 80));
Hope this helps. If you have any doubts regarding this, I'll be happy to help.
Note: Don't use "https" for proxy. Give only domain name.