Please, need help. I'm having this error java.io.FileNotFoundException: http://news.yandex.ru/quotes/1507.png (can be seen by browser) while saving it to my internal storage. this is my method:
void downloadGraph(String link){ try {
URL url = new URL(link);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setDoOutput(true);
urlConnection.connect();
File dbDirectory = new File(mctx.getFilesDir().getAbsolutePath()+ File.separator+"yqimages/");
if(!dbDirectory.exists())dbDirectory.mkdir();
String fname=link.substring(link.lastIndexOf("/")+1,link.length());
File file = new File(dbDirectory, fname);
FileOutputStream fileOutput = new FileOutputStream(file);
InputStream inputStream = urlConnection.getInputStream();
byte[] buffer = new byte[1024];
int bufferLength;
while ( (bufferLength = inputStream.read(buffer)) > 0 ) {
fileOutput.write(buffer, 0, bufferLength);
}
fileOutput.close();
} catch (final Exception e) {
e.printStackTrace();
}
}
Can you write a method to download\save this specific image (shown above)? Any help is appreciated! Get it!! the problem is not in the code, it's in the image https://news.yandex.ru/quotes/1507.png. For some reason this picture can't be saved while the other ones do. Has it something to do with "httpS://"?