*Stream ----- byte oriented
*der ----- char oriented
Buffered*----- add buffer
Print* ----- format
URL url = new URL(
"http://docs.oracle.com/javase/tutorial/networking/sockets/examples/KnockKnockServer.java");
URLConnection uc = url.openConnection();
InputStream in = null;
OutputStream out = null;
try {
in = new BufferedInputStream(uc.getInputStream());
out = new BufferedOutputStream(new FileOutputStream("test1"));
int c;
while ((c = in.read()) != -1) {
out.write(c);
}
} catch (Exception ex) {
// do sth
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}