“Java Unduh File Gambar” Kode Jawaban

Java Unduh File Gambar

 URL url = new URL("http://www.yahoo.com/image_to_read.jpg");
InputStream in = new BufferedInputStream(url.openStream());
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int n = 0;
while (-1!=(n=in.read(buf)))
{
   out.write(buf, 0, n);
}
out.close();
in.close();
byte[] response = out.toByteArray();
DreamCoder

Java Unduh File Gambar

(throws IOException)

Image image = null;
try {
    URL url = new URL("http://www.yahoo.com/image_to_read.jpg");
    image = ImageIO.read(url);
} catch (IOException e) {
}
DreamCoder

Java Unduh File Gambar

URL url = new URL("http://upload.wikimedia.org/wikipedia/commons/9/9c/Image-Porkeri_001.jpg");
InputStream in = new BufferedInputStream(url.openStream());
OutputStream out = new BufferedOutputStream(new FileOutputStream("Image-Porkeri_001.jpg"));

for ( int i; (i = in.read()) != -1; ) {
    out.write(i);
}
in.close();
out.close();
DreamCoder

Jawaban yang mirip dengan “Java Unduh File Gambar”

Pertanyaan yang mirip dengan “Java Unduh File Gambar”

Lebih banyak jawaban terkait untuk “Java Unduh File Gambar” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya