505错误是“HTTP错误505 HTTP版本不支持“(可能与”java.net。URISyntaxException:格式不正确的IPv6地址“有关)。
我通过编码(网址),并且包装在一个URI解决您的问题:
public static void main(String args[]) throws IOException, URISyntaxException {
URI uri = new URI(
"http",
"52.66.123.140:8080",
"/TATADHPFILES/1239/TDH Items/149387773752120170504_113201.jpg",
"Implementation", "Java");
URL url = uri.toURL();
try {
BufferedImage img = ImageIO.read(url);
// --- your original code will also now work ---
URLConnection conn = url.openConnection();
InputStream in = conn.getInputStream();
// ---------------------------------------
System.out.println("tester");
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
我能在设定的System.out.println(使用的IntelliJ)断点(“测试”) ; - 并能够查看img变量(显示“正确”的图像)。
你原来的代码也将正常工作。
505是:不支持HTTP版本。 – Jens
我该如何解决这个问题? –
也许这将帮助你:https://dzone.com/articles/solr-tomcat-and-http11-505 – ema