我可以在瀏覽器中打開此圖像,但它無法在我的 java 應(yīng)用程序中加載,為什么?它應(yīng)該是一個免費使用的數(shù)據(jù)庫,我不明白為什么我不能使用它。我正在使用這段代碼:public static String getContentsFromURL(String address){ String contents = ""; try{ URL url = new URL(address); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(url.openStream())); String line; while((line = bufferedReader.readLine()) != null){ contents += line; } bufferedReader.close(); }catch(IOException e){ e.printStackTrace(); } return contents;}我收到 IIOException“找不到輸入文件!”
1 回答

烙印99
TA貢獻(xiàn)1829條經(jīng)驗 獲得超13個贊
試試這個代碼
URL url = new URL(" Image image1 = ImageIO.read(url);
來自我的調(diào)試器的圖像屏幕截圖。
添加回答
舉報
0/150
提交
取消