Skip to main content

Vê se isso aqui funciona pra voce: URL urlObj = new URL(//img que vc quer baixar.);
HttpURLConnection httpConnection = (HttpURLConnection)urlObj.openConnection(); httpConnection.setRequestMethod("GET"); InputStream inputStream = httpConnection.getInputStream(); OutputStream outputStream = null; try { int read = 0; byte[] bytes = new byte[1024]; outputStream = new FileOutputStream(new File(pathToSave)); while ((read = inputStream.read(bytes)) != -1) { outputStream.write(bytes, 0, read); } } catch (FileNotFoundException ex) { ex.getMessage(); } catch (IOException ex) { ex.getMessage(); } finally { try { if (outputStream != null) { outputStream.close(); } } catch (IOException ex) { ex.getMessage(); } }

URL urlObj = new URL(//img que vc quer baixar.);                                    
HttpURLConnection  httpConnection = (HttpURLConnection)urlObj.openConnection();
httpConnection.setRequestMethod("GET");
InputStream inputStream = httpConnection.getInputStream();
OutputStream outputStream = null;
try {
    int read = 0;
    byte[] bytes = new byte[1024];
    outputStream = new FileOutputStream(new File(pathToSave));
    while ((read = inputStream.read(bytes)) != -1) {
        outputStream.write(bytes, 0, read);
    }
} catch (FileNotFoundException ex) {
    ex.getMessage();
} catch (IOException ex) {
    ex.getMessage();
} finally {
    try {
        if (outputStream != null) {
            outputStream.close();
        }
    } catch (IOException ex) {
        ex.getMessage();
    }
}

Vê se isso aqui funciona pra voce: URL urlObj = new URL(//img que vc quer baixar.);
HttpURLConnection httpConnection = (HttpURLConnection)urlObj.openConnection(); httpConnection.setRequestMethod("GET"); InputStream inputStream = httpConnection.getInputStream(); OutputStream outputStream = null; try { int read = 0; byte[] bytes = new byte[1024]; outputStream = new FileOutputStream(new File(pathToSave)); while ((read = inputStream.read(bytes)) != -1) { outputStream.write(bytes, 0, read); } } catch (FileNotFoundException ex) { ex.getMessage(); } catch (IOException ex) { ex.getMessage(); } finally { try { if (outputStream != null) { outputStream.close(); } } catch (IOException ex) { ex.getMessage(); } }

Vê se isso aqui funciona pra voce:

URL urlObj = new URL(//img que vc quer baixar.);                                    
HttpURLConnection  httpConnection = (HttpURLConnection)urlObj.openConnection();
httpConnection.setRequestMethod("GET");
InputStream inputStream = httpConnection.getInputStream();
OutputStream outputStream = null;
try {
    int read = 0;
    byte[] bytes = new byte[1024];
    outputStream = new FileOutputStream(new File(pathToSave));
    while ((read = inputStream.read(bytes)) != -1) {
        outputStream.write(bytes, 0, read);
    }
} catch (FileNotFoundException ex) {
    ex.getMessage();
} catch (IOException ex) {
    ex.getMessage();
} finally {
    try {
        if (outputStream != null) {
            outputStream.close();
        }
    } catch (IOException ex) {
        ex.getMessage();
    }
}
Fonte Link
leonardo
  • 373
  • 1
  • 6

Vê se isso aqui funciona pra voce: URL urlObj = new URL(//img que vc quer baixar.);
HttpURLConnection httpConnection = (HttpURLConnection)urlObj.openConnection(); httpConnection.setRequestMethod("GET"); InputStream inputStream = httpConnection.getInputStream(); OutputStream outputStream = null; try { int read = 0; byte[] bytes = new byte[1024]; outputStream = new FileOutputStream(new File(pathToSave)); while ((read = inputStream.read(bytes)) != -1) { outputStream.write(bytes, 0, read); } } catch (FileNotFoundException ex) { ex.getMessage(); } catch (IOException ex) { ex.getMessage(); } finally { try { if (outputStream != null) { outputStream.close(); } } catch (IOException ex) { ex.getMessage(); } }