我在课堂下面。
public class Gettype {
public static void main(String[] args) throws IOException, ParseException {
URL url = new URL("http://static.ddmcdn.com/gif/recipes/octo-arm-150513 200x200.jpg");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty(
"User-Agent",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31");
connection.getInputStream();
}
抛出FileNotFoundException
。但是当我通过浏览器访问相同的URL(http://static.ddmcdn.com/gif/recipes/octo-arm-150513 200x200.jpg)时,它可以工作。请帮帮我。
答案 0 :(得分:1)
您的网址是" http://static.ddmcdn.com/gif/recipes/octo-arm-150513%20200x200.jpg"
将空格替换为%20