NOTE:I apologize if this is a stupid question, I am new to web server interaction, and I have yet to find any useful information online to help with this issue.
I am trying to install an image off of a web server using the following code:
public static void main(String args[]){
try {
BufferedImage image = ImageIO.read(new URL("http://medialink.atspace.cc/uploads/murphy/apple.jpg"));
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
This code gives the following error:
javax.imageio.IIOException: Can't get input stream from URL!
at javax.imageio.ImageIO.read(Unknown Source)
at MediaLinkMain.main(MediaLinkMain.java:24)
Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://medialink.atspace.cc/uploads/murphy/apple.jpg
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
... 2 more
The image is on a subdomain I have with atspace.com. The same code with for example to google logo image at address: https://www.google.com/images/srpr/logo11w.png
By default atspace had a setting called "directory protection" under their hosting settings. Prior to disabling that I was strangely not able to view the image at it's address(http://medialink.atspace.cc/uploads/murphy/apple.jpg), unless i added it to a webpage, and right clicked + pressed view image.
You may also want to note using the following code:
URL url = new URL(addr + "/list.dat");
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
for(String line = reader.readLine(); line != null; line=reader.readLine()){
//Use data here
}
Runs without issue for a file in the exact same directory as the image.