import java.io.*; //used to access the DataInputStream and FileOutputStream class that will get and save the file to the directory program import java.net.*; //used to access the URL and URL connection class to access websites
byte[] b = new byte[1];
urlConnect.connect();
while (-1 != di.read(b, 0, 1)) fo.write(b, 0, 1); di.close(); fo.close();
import java.io.*; //used to access the DataInputStream and FileOutputStream class that will get and save the file to the directory program import java.net.*; //used to access the URL and URL connection class to access websites public class imgFromURL { byte[] b = new byte[1]; //data type to save memory space of the file urlConnect.connect(); // get the connection to the site DataInputStream di = new DataInputStream(urlConnect.getInputStream()); //have the input to the connection FileOutputStream fo = new FileOutputStream("print_0.png"); //download the file and have it named print_0.png while (-1 != di.read(b, 0, 1)) //download the image file fo.write(b, 0, 1); di.close(); // close DataInputStream fo.close(); // close FileOutputStream } }