特定のURLから画像を取得しようとしていますが、FileNotFoundException
がスローされます。ブラウザからURLを開こうとすると、画像が表示されます。助けてください。以下は私のコードです。ありがとう。で...URL - Androidの画像ファイルのFileNotFoundException
FileOutputStream f = new FileOutputStream(new File(root, FILENAME));
String fileURL = "http://sposter.smartag.my/images/KFC_Voucher.jpg";
String FILENAME = "caldophilus.jpg";
URL u = new URL(fileURL);
HttpURLConnection c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
File root = Environment.getExternalStorageDirectory();
FileOutputStream f = new FileOutputStream(new File(root, FILENAME));
InputStream x=c.getInputStream();
int size=x.available();
byte b[]= new byte[size];
x.read(b);
f.write(b);
f.flush();
f.close();
を見てみましょうあなたは昨日同じ質問を掲載しています。あなたは適切な答えを得られないのですか? – Android
昨日私は画像を取得するためにwebserviceを使いましたが、現在はURLを使用しています... –
@ chinna_82私は404を表示しているborwserにあなたのURLをオープンしました - ファイルまたはディレクトリが見つかりません。 –